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

@@ -130,10 +130,6 @@ int main(int argc, char *argv[])
tx = bitcoin_tx(NULL, chainparams, 1, 2, 0);
/* Our input spends the anchor tx output. */
bitcoin_tx_add_input(tx, &funding_txid, funding_outnum,
BITCOIN_TX_DEFAULT_SEQUENCE, funding_amount, NULL);
num_outputs = 0;
if (amount_msat_greater_eq_sat(local_msat, dust_limit)) {
u8 *script = scriptpubkey_p2wpkh(NULL, &outkey[LOCAL]);
@@ -165,6 +161,11 @@ int main(int argc, char *argv[])
printf("# funding witness script = %s\n",
tal_hex(NULL, funding_wscript));
/* Our input spends the anchor tx output. */
bitcoin_tx_add_input(tx, &funding_txid, funding_outnum,
BITCOIN_TX_DEFAULT_SEQUENCE, NULL,
funding_amount, NULL, funding_wscript);
sign_tx_input(tx, 0, NULL, funding_wscript,
&funding_privkey[LOCAL],
&funding_pubkey[LOCAL],