diff --git a/wallet/reservation.c b/wallet/reservation.c index f7e458c66..4d3b470df 100644 --- a/wallet/reservation.c +++ b/wallet/reservation.c @@ -261,17 +261,21 @@ static bool inputs_sufficient(struct amount_sat input, return false; } -static struct wally_psbt *psbt_using_utxos(const tal_t *ctx, - struct wallet *wallet, - struct utxo **utxos, - u32 nlocktime, - u32 nsequence) +struct wally_psbt *psbt_using_utxos(const tal_t *ctx, + struct wallet *wallet, + struct utxo **utxos, + u32 nlocktime, + u32 nsequence, + struct wally_psbt *base) { struct pubkey key; u8 *scriptSig, *scriptPubkey, *redeemscript; struct wally_psbt *psbt; - psbt = create_psbt(ctx, tal_count(utxos), 0, nlocktime); + if (base) + psbt = base; + else + psbt = create_psbt(ctx, tal_count(utxos), 0, nlocktime); for (size_t i = 0; i < tal_count(utxos); i++) { u32 this_nsequence; @@ -357,7 +361,8 @@ static struct command_result *finish_psbt(struct command *cmd, } psbt = psbt_using_utxos(cmd, cmd->ld->wallet, utxos, - *locktime, BITCOIN_TX_RBF_SEQUENCE); + *locktime, BITCOIN_TX_RBF_SEQUENCE, + NULL); assert(psbt->version == 2); /* Should we add a change output for the excess? */ if (excess_as_change) { diff --git a/wallet/wallet.h b/wallet/wallet.h index b6c9bb408..5dcf313dd 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -1748,4 +1748,12 @@ struct wallet_htlc_iter *wallet_htlcs_next(struct wallet *w, struct amount_msat *msat, struct sha256 *payment_hash, enum htlc_state *hstate); + +/* Make a PSBT from these utxos, or enhance @base if non-NULL. */ +struct wally_psbt *psbt_using_utxos(const tal_t *ctx, + struct wallet *wallet, + struct utxo **utxos, + u32 nlocktime, + u32 nsequence, + struct wally_psbt *base); #endif /* LIGHTNING_WALLET_WALLET_H */