From f0ea4d60b97feb9ecdb87691ee3c11fcc88dc09a Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 26 Feb 2022 11:20:33 +1030 Subject: [PATCH] onchaind: fix minor leaks. Not actually leaks, but they do live longer than they need. Signed-off-by: Rusty Russell --- bitcoin/tx.c | 4 ++-- bitcoin/tx.h | 2 +- common/htlc_tx.c | 2 +- onchaind/onchaind.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 60e2f3246..15c869862 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -59,7 +59,7 @@ done: } int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script, - u8 *wscript, struct amount_sat amount) + const u8 *wscript, struct amount_sat amount) { size_t i = tx->wtx->num_outputs; struct wally_tx_output *output; @@ -197,7 +197,7 @@ int bitcoin_tx_add_input(struct bitcoin_tx *tx, input_wscript, NULL); if (input_wscript) { - scriptPubkey = scriptpubkey_p2wsh(tx->psbt, input_wscript); + scriptPubkey = scriptpubkey_p2wsh(tmpctx, input_wscript); } assert(scriptPubkey); diff --git a/bitcoin/tx.h b/bitcoin/tx.h index 170371094..0d0e7e414 100644 --- a/bitcoin/tx.h +++ b/bitcoin/tx.h @@ -97,7 +97,7 @@ struct wally_tx_output *wally_tx_output(const tal_t *ctx, /* Add one output to tx. */ int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script, - u8 *wscript, + const u8 *wscript, struct amount_sat amount); /* Set the locktime for a transaction */ diff --git a/common/htlc_tx.c b/common/htlc_tx.c index 50552128c..e80ea1375 100644 --- a/common/htlc_tx.c +++ b/common/htlc_tx.c @@ -62,7 +62,7 @@ static struct bitcoin_tx *htlc_tx(const tal_t *ctx, wscript = bitcoin_wscript_htlc_tx(tx, to_self_delay, revocation_pubkey, local_delayedkey); - bitcoin_tx_add_output(tx, scriptpubkey_p2wsh(tx, wscript), + bitcoin_tx_add_output(tx, scriptpubkey_p2wsh(tmpctx, wscript), wscript, amount); bitcoin_tx_finalize(tx); diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index ecd60166a..ae8eb2a5b 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -592,7 +592,7 @@ static struct bitcoin_tx *tx_to_us(const tal_t *ctx, NULL, out->sat, NULL, wscript); bitcoin_tx_add_output( - tx, scriptpubkey_p2wpkh(tx, &our_wallet_pubkey), NULL, out->sat); + tx, scriptpubkey_p2wpkh(tmpctx, &our_wallet_pubkey), NULL, out->sat); /* Worst-case sig is 73 bytes */ weight = bitcoin_tx_weight(tx) + 1 + 3 + 73 + 0 + tal_count(wscript);