@@ -74,7 +74,7 @@ struct bitcoin_tx *tx_spending_utxos(const tal_t *ctx,
7474 u32 nsequence )
7575{
7676 struct pubkey key ;
77- u8 * scriptSig , * scriptPubkey , * redeemscript ;
77+ u8 * scriptSig , * redeemscript ;
7878
7979 size_t outcount = add_change_output ? 1 + num_output : num_output ;
8080 struct bitcoin_tx * tx = bitcoin_tx (ctx , chainparams , tal_count (utxos ),
@@ -83,30 +83,26 @@ struct bitcoin_tx *tx_spending_utxos(const tal_t *ctx,
8383 for (size_t i = 0 ; i < tal_count (utxos ); i ++ ) {
8484 if (utxos [i ]-> is_p2sh && bip32_base ) {
8585 bip32_pubkey (bip32_base , & key , utxos [i ]-> keyindex );
86- scriptSig = bitcoin_scriptsig_p2sh_p2wpkh (tmpctx , & key );
87- redeemscript = bitcoin_redeem_p2sh_p2wpkh (tmpctx , & key );
88- scriptPubkey = scriptpubkey_p2sh (tmpctx , redeemscript );
89-
90- /* Make sure we've got the right info! */
91- if (utxos [i ]-> scriptPubkey )
92- assert (memeq (utxos [i ]-> scriptPubkey ,
93- tal_bytelen (utxos [i ]-> scriptPubkey ),
94- scriptPubkey , tal_bytelen (scriptPubkey )));
86+ scriptSig =
87+ bitcoin_scriptsig_p2sh_p2wpkh (tmpctx , & key );
88+ redeemscript =
89+ bitcoin_redeem_p2sh_p2wpkh (tmpctx , & key );
90+
9591 } else {
9692 scriptSig = NULL ;
9793 redeemscript = NULL ;
98- /* We can't definitively derive the pubkey without
99- * hitting the HSM, so we don't */
100- scriptPubkey = utxos [i ]-> scriptPubkey ;
10194 }
10295
103- bitcoin_tx_add_input (tx , & utxos [i ]-> txid , utxos [i ]-> outnum ,
104- nsequence , scriptSig , utxos [i ]-> amount ,
105- scriptPubkey , NULL );
96+ bitcoin_tx_add_input (tx , & utxos [i ]-> txid ,
97+ utxos [i ]-> outnum ,
98+ nsequence ,
99+ scriptSig , utxos [i ]-> amount ,
100+ utxos [i ]-> scriptPubkey , NULL );
106101
107102 /* Add redeemscript to the PSBT input */
108103 if (redeemscript )
109- psbt_input_set_redeemscript (tx -> psbt , i , redeemscript );
104+ psbt_input_set_redeemscript (tx -> psbt , i ,
105+ redeemscript );
110106
111107 }
112108
0 commit comments