@@ -214,7 +214,10 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
214
214
scriptPubkeys := make ([]string , len (inputUTXOs ))
215
215
216
216
for i , utxo := range inputUTXOs {
217
- inputs [i ] = btcjson.TransactionInput {utxo .TxID , utxo .Vout }
217
+ inputs [i ] = btcjson.TransactionInput {
218
+ Txid : utxo .TxID ,
219
+ Vout : utxo .Vout ,
220
+ }
218
221
inputSats += btcutil .Amount (utxo .Amount * btcutil .SatoshiPerBitcoin )
219
222
amounts [i ] = utxo .Amount
220
223
scriptPubkeys [i ] = utxo .ScriptPubKey
@@ -253,7 +256,7 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
253
256
tx .TxOut [1 ], tx .TxOut [2 ] = tx .TxOut [2 ], tx .TxOut [1 ]
254
257
255
258
// make sure that TxOut[0] is sent to "to" address; TxOut[2] is change to oneself. TxOut[1] is memo.
256
- if bytes .Compare (tx .TxOut [0 ].PkScript [2 :], to .ScriptAddress ()) != 0 {
259
+ if ! bytes .Equal (tx .TxOut [0 ].PkScript [2 :], to .ScriptAddress ()) {
257
260
runner .Logger .Info ("tx.TxOut[0].PkScript: %x" , tx .TxOut [0 ].PkScript )
258
261
runner .Logger .Info ("to.ScriptAddress(): %x" , to .ScriptAddress ())
259
262
runner .Logger .Info ("swapping txout[0] with txout[2]" )
@@ -281,6 +284,36 @@ func (runner *E2ERunner) SendToTSSFromDeployerWithMemo(
281
284
if err != nil {
282
285
panic (err )
283
286
}
287
+
288
+ // print transaction inputs
289
+ runner .Logger .Info ("SignRawTransactionWithWallet2 input: %+v" , inputsForSign )
290
+ for _ , input := range inputUTXOs {
291
+ runner .Logger .Print (" txid: %s" , input .TxID )
292
+ runner .Logger .Print (" vout: %d" , input .Vout )
293
+ runner .Logger .Print (" address: %s" , input .Address )
294
+ runner .Logger .Print (" amount: %f" , input .Amount )
295
+ runner .Logger .Print (" confirmations: %d" , input .Confirmations )
296
+ }
297
+
298
+ // retry for 10 times if not signed
299
+ if ! signed {
300
+ for i := 0 ; i < 10 ; i ++ {
301
+ runner .Logger .Print (fmt .Sprintf ("retrying SignRawTransactionWithWallet2: %d" , i + 1 ))
302
+ stx , signed , err = btcRPC .SignRawTransactionWithWallet2 (tx , inputsForSign )
303
+ if err != nil {
304
+ panic (err )
305
+ }
306
+ if signed {
307
+ break
308
+ }
309
+ time .Sleep (1 * time .Second )
310
+ _ , err = btcRPC .GenerateToAddress (1 , btcDeployerAddress , nil )
311
+ if err != nil {
312
+ panic (err )
313
+ }
314
+ }
315
+ }
316
+
284
317
if ! signed {
285
318
panic ("btc transaction not signed" )
286
319
}
0 commit comments