Browse Source

bitcoin/psbt: psbt_finalize needs a tal ctx.

Since it returns a wally_tx.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-experimental
Rusty Russell 4 years ago
parent
commit
77b62d9e42
  1. 4
      bitcoin/psbt.c
  2. 3
      bitcoin/psbt.h
  3. 2
      bitcoin/tx.c
  4. 2
      lightningd/dual_open_control.c
  5. 2
      wallet/walletrpc.c

4
bitcoin/psbt.c

@ -524,7 +524,8 @@ static void wally_tx_destroy(struct wally_tx *wtx)
wally_tx_free(wtx); wally_tx_free(wtx);
} }
struct wally_tx *psbt_finalize(struct wally_psbt *psbt, bool finalize_in_place) struct wally_tx *psbt_finalize(const tal_t *ctx,
struct wally_psbt *psbt, bool finalize_in_place)
{ {
struct wally_psbt *tmppsbt; struct wally_psbt *tmppsbt;
struct wally_tx *wtx; struct wally_tx *wtx;
@ -585,6 +586,7 @@ struct wally_tx *psbt_finalize(struct wally_psbt *psbt, bool finalize_in_place)
if (psbt_is_finalized(tmppsbt) if (psbt_is_finalized(tmppsbt)
&& wally_psbt_extract(tmppsbt, &wtx) == WALLY_OK) { && wally_psbt_extract(tmppsbt, &wtx) == WALLY_OK) {
tal_steal(ctx, wtx);
tal_add_destructor(wtx, wally_tx_destroy); tal_add_destructor(wtx, wally_tx_destroy);
if (!finalize_in_place) if (!finalize_in_place)
wally_psbt_free(tmppsbt); wally_psbt_free(tmppsbt);

3
bitcoin/psbt.h

@ -79,7 +79,8 @@ void psbt_txid(const tal_t *ctx,
*/ */
void psbt_elements_normalize_fees(struct wally_psbt *psbt); void psbt_elements_normalize_fees(struct wally_psbt *psbt);
struct wally_tx *psbt_finalize(struct wally_psbt *psbt, bool finalize_in_place); struct wally_tx *psbt_finalize(const tal_t *ctx,
struct wally_psbt *psbt, bool finalize_in_place);
/* psbt_make_key - Create a new, proprietary c-lightning key /* psbt_make_key - Create a new, proprietary c-lightning key
* *

2
bitcoin/tx.c

@ -502,7 +502,7 @@ struct bitcoin_tx *bitcoin_tx_with_psbt(const tal_t *ctx, struct wally_psbt *psb
psbt->tx->num_outputs, psbt->tx->num_outputs,
psbt->tx->locktime); psbt->tx->locktime);
wally_tx_free(tx->wtx); wally_tx_free(tx->wtx);
tx->wtx = psbt_finalize(psbt, false); tx->wtx = psbt_finalize(tx, psbt, false);
if (!tx->wtx && wally_tx_clone_alloc(psbt->tx, 0, &tx->wtx) != WALLY_OK) if (!tx->wtx && wally_tx_clone_alloc(psbt->tx, 0, &tx->wtx) != WALLY_OK)
return NULL; return NULL;

2
lightningd/dual_open_control.c

@ -590,7 +590,7 @@ openchannel2_sign_hook_cb(struct openchannel2_psbt_payload *payload STEALS)
tal_steal(tmpctx, payload); tal_steal(tmpctx, payload);
/* Finalize it, if not already. It shouldn't work entirely */ /* Finalize it, if not already. It shouldn't work entirely */
psbt_finalize(payload->psbt, true); psbt_finalize(tmpctx, payload->psbt, true);
if (!psbt_side_finalized(payload->ld->log, payload->psbt, REMOTE)) if (!psbt_side_finalized(payload->ld->log, payload->psbt, REMOTE))
fatal("Plugin must return a 'psbt' with signatures for their inputs" fatal("Plugin must return a 'psbt' with signatures for their inputs"

2
wallet/walletrpc.c

@ -812,7 +812,7 @@ static struct command_result *json_sendpsbt(struct command *cmd,
sending = tal(cmd, struct sending_psbt); sending = tal(cmd, struct sending_psbt);
sending->cmd = cmd; sending->cmd = cmd;
sending->wtx = tal_steal(sending, psbt_finalize(psbt, true)); sending->wtx = psbt_finalize(sending, psbt, true);
if (!sending->wtx) if (!sending->wtx)
return command_fail(cmd, LIGHTNINGD, return command_fail(cmd, LIGHTNINGD,
"PSBT not finalizeable %s", "PSBT not finalizeable %s",

Loading…
Cancel
Save