Browse Source

wellet: use create_psbt and psbt_append_input instead of constructing via bitcoin_tx.

Suggested-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
bump-pyln-proto
Rusty Russell 4 years ago
parent
commit
73832d1488
  1. 18
      wallet/reservation.c

18
wallet/reservation.c

@ -219,10 +219,9 @@ static struct wally_psbt *psbt_using_utxos(const tal_t *ctx,
{ {
struct pubkey key; struct pubkey key;
u8 *scriptSig, *scriptPubkey, *redeemscript; u8 *scriptSig, *scriptPubkey, *redeemscript;
struct bitcoin_tx *tx; struct wally_psbt *psbt;
/* FIXME: Currently the easiest way to get a PSBT is via a tx */ psbt = create_psbt(ctx, tal_count(utxos), 0, nlocktime);
tx = bitcoin_tx(ctx, chainparams, tal_count(utxos), 0, nlocktime);
for (size_t i = 0; i < tal_count(utxos); i++) { for (size_t i = 0; i < tal_count(utxos); i++) {
u32 this_nsequence; u32 this_nsequence;
@ -256,17 +255,12 @@ static struct wally_psbt *psbt_using_utxos(const tal_t *ctx,
else else
this_nsequence = nsequence; this_nsequence = nsequence;
bitcoin_tx_add_input(tx, &utxos[i]->txid, utxos[i]->outnum, psbt_append_input(psbt, &utxos[i]->txid, utxos[i]->outnum,
this_nsequence, scriptSig, utxos[i]->amount, this_nsequence, scriptSig, utxos[i]->amount,
scriptPubkey, NULL); scriptPubkey, NULL, redeemscript);
/* Add redeemscript to the PSBT input */
if (redeemscript)
psbt_input_set_redeemscript(tx->psbt, i, redeemscript);
} }
return tx->psbt; return psbt;
} }
static struct command_result *finish_psbt(struct command *cmd, static struct command_result *finish_psbt(struct command *cmd,

Loading…
Cancel
Save