1
+ package com .flashwifi .flashwrapper ;
1
2
2
- import Model .*;
3
+ import com . flashwifi . flashwrapper . Model .*;
3
4
4
5
import java .io .IOException ;
5
6
import java .util .ArrayList ;
@@ -96,38 +97,17 @@ public static void main(String[] argv) throws Exception {
96
97
97
98
System .out .println ("Channel Setup!" );
98
99
99
-
100
100
ArrayList <Transfer > transfers = new ArrayList <>();
101
- transfers .add (new Transfer (twoSettlement , 200 ));
101
+ transfers .add (new Transfer (twoSettlement , 1 ));
102
+ transfers .add (new Transfer (twoSettlement , 400 ));
102
103
103
104
System .out .println (oneFlash );
104
105
105
106
System .out .println ("Creating a transaction: 200 to " + twoSettlement );
106
107
ArrayList <Bundle > bundles = Helpers .createTransaction (oneFlash , transfers , false );
107
108
108
- System .out .println ("[SUCCESS] createTransaction completed" );
109
-
110
- // Sign the bundles.
111
- // Get signatures for the bundles
112
- ArrayList <Signature > oneSignatures = Helpers .signTransaction (oneFlash , bundles );
113
-
114
- // Generate USER TWO'S Singatures
115
- ArrayList <Signature > twoSignatures = Helpers .signTransaction (twoFlash , bundles );
116
-
117
- System .out .println ("[SUCCESS] Created signatures for users." );
118
-
119
- // Sign bundle with your USER ONE'S signatures
120
- ArrayList <Bundle > signedBundles = IotaFlashBridge .appliedSignatures (bundles , oneSignatures );
121
-
122
- System .out .println ("[SUCCESS] Parial applied Signature for User one on transfer bundle" );
123
-
124
-
125
- // ADD USER TWOS'S signatures to the partially signed bundles
126
- signedBundles = IotaFlashBridge .appliedSignatures (signedBundles , twoSignatures );
127
-
128
- System .out .println ("[SUCCESS] Signed bundle bu second user. Bundle ready." );
129
-
130
-
109
+ ArrayList <Bundle > partialSignedBundles = signTransfer (bundles , oneFlash );
110
+ ArrayList <Bundle > signedBundles = signTransfer (partialSignedBundles , twoFlash );
131
111
/////////////////////////////////
132
112
/// APPLY SIGNED BUNDLES
133
113
@@ -154,7 +134,7 @@ public static void main(String[] argv) throws Exception {
154
134
/*
155
135
156
136
// Supplying the CORRECT varibles to create a closing bundle
157
- bundles = Helpers.createTransaction(
137
+ bundles = com.flashwifi.flashwrapper. Helpers.createTransaction(
158
138
oneFlash,
159
139
oneFlash.getFlash().getSettlementAddresses(),
160
140
true
@@ -164,10 +144,10 @@ public static void main(String[] argv) throws Exception {
164
144
/// SIGN BUNDLES
165
145
166
146
// Get signatures for the bundles
167
- oneSignatures = Helpers.signTransaction(oneFlash, bundles)
147
+ oneSignatures = com.flashwifi.flashwrapper. Helpers.signTransaction(oneFlash, bundles)
168
148
169
149
// Generate USER TWO'S Singatures
170
- twoSignatures = Helpers.signTransaction(twoFlash, bundles)
150
+ twoSignatures = com.flashwifi.flashwrapper. Helpers.signTransaction(twoFlash, bundles)
171
151
172
152
// Sign bundle with your USER ONE'S signatures
173
153
signedBundles = transfer.appliedSignatures(bundles, oneSignatures)
@@ -179,19 +159,30 @@ public static void main(String[] argv) throws Exception {
179
159
/// APPLY SIGNED BUNDLES
180
160
181
161
// Apply transfers to User ONE
182
- oneFlash = Helpers.applyTransfers(oneFlash, signedBundles)
162
+ oneFlash = com.flashwifi.flashwrapper. Helpers.applyTransfers(oneFlash, signedBundles)
183
163
// Save latest channel bundles
184
164
oneFlash.bundles = signedBundles
185
165
186
166
// Apply transfers to User TWO
187
- twoFlash = Helpers.applyTransfers(twoFlash, signedBundles)
167
+ twoFlash = com.flashwifi.flashwrapper. Helpers.applyTransfers(twoFlash, signedBundles)
188
168
// Save latest channel bundles
189
169
twoFlash.bundles = signedBundles
190
170
191
171
console.log("Channel Closed")
192
172
console.log("Final Bundle to be attached: ")*/
193
173
}
194
174
175
+ private static ArrayList <Bundle > signTransfer (ArrayList <Bundle > bundles , UserObject user ) {
176
+ System .out .println ("[SUCCESS] Created signatures for users." );
177
+ ArrayList <Signature > oneSignatures = Helpers .signTransaction (user , bundles );
178
+
179
+ System .out .println ("[SUCCESS] Parial applied Signature for User one on transfer bundle" );
180
+ // Sign bundle with your USER ONE'S signatures
181
+ ArrayList <Bundle > signedBundles = IotaFlashBridge .appliedSignatures (bundles , oneSignatures );
182
+
183
+ return signedBundles ;
184
+ }
185
+
195
186
private static void setupUser (UserObject user , int TREE_DEPTH ) {
196
187
// Create digests for the start of the channel
197
188
for (int i = 0 ; i < TREE_DEPTH + 1 ; i ++) {
0 commit comments