tx-psbt: pass in the witness script (if known) when adding an input

Update the `bitcoin_tx_add_input` interface to accept a witness script
and or scriptPubkey.

We save the amount + witness script + witness program (if known) to
the PSBT object for a transaction when creating an input.
This commit is contained in:
niftynei
2020-05-21 14:46:19 -05:00
committed by Christian Decker
parent a04f0fe250
commit dc868630a8
22 changed files with 116 additions and 53 deletions

View File

@@ -79,6 +79,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
const struct bitcoin_txid *funding_txid,
unsigned int funding_txout,
struct amount_sat funding,
const u8 *funding_wscript,
enum side opener,
u16 to_self_delay,
const struct keyset *keyset,
@@ -289,7 +290,8 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
* * `txin[0]` sequence: upper 8 bits are 0x80, lower 24 bits are upper 24 bits of the obscured commitment number
*/
u32 sequence = (0x80000000 | ((obscured_commitment_number>>24) & 0xFFFFFF));
bitcoin_tx_add_input(tx, funding_txid, funding_txout, sequence, funding, NULL);
bitcoin_tx_add_input(tx, funding_txid, funding_txout,
sequence, NULL, funding, NULL, funding_wscript);
/* Identify the direct outputs (to_us, to_them). */
if (direct_outputs != NULL) {