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

@@ -62,6 +62,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
const struct bitcoin_txid *funding_txid,
unsigned int funding_txout,
struct amount_sat funding,
u8 *funding_wscript,
enum side opener,
u16 to_self_delay,
const struct keyset *keyset,
@@ -239,7 +240,8 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
* * `txin[0]` script bytes: 0
*/
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);
if (direct_outputs != NULL) {
direct_outputs[LOCAL] = direct_outputs[REMOTE] = NULL;