Skip to content

Commit 0a58ec3

Browse files
committed
PSBT: Clean up PSBT chunk allocations
Cleaning up the memory hierarchy of PSBT usage in splicing and `psbt_finalize_input`
1 parent 3e89e59 commit 0a58ec3

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

channeld/channeld.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4234,7 +4234,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
42344234

42354235
/* Peer may have modified our PSBT so we return it to the user here */
42364236
outmsg = towire_channeld_splice_confirmed_update(NULL,
4237-
ictx->current_psbt,
4237+
peer->splicing->current_psbt,
42384238
false, false);
42394239
wire_sync_write(MASTER_FD, take(outmsg));
42404240
audit_psbt(peer->splicing->current_psbt, peer->splicing->current_psbt);
@@ -4275,7 +4275,7 @@ static void splice_initiator_user_signed(struct peer *peer, const u8 *inmsg)
42754275
return;
42764276
}
42774277

4278-
if (!fromwire_channeld_splice_signed(inflight, inmsg, &signed_psbt,
4278+
if (!fromwire_channeld_splice_signed(tmpctx, inmsg, &signed_psbt,
42794279
&peer->splicing->force_sign_first))
42804280
master_badmsg(WIRE_CHANNELD_SPLICE_SIGNED, inmsg);
42814281

common/interactivetx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ char *process_interactivetx_updates(const tal_t *ctx,
588588

589589
tal_wally_start();
590590
wally_psbt_input_set_utxo(in, tx->wtx);
591-
tal_wally_end(ictx);
591+
tal_wally_end(ictx->current_psbt);
592592

593593
psbt_input_set_serial_id(ictx->current_psbt,
594594
in, serial_id);

common/psbt_internal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,12 @@ void psbt_finalize_input(const tal_t *ctx,
106106
redeem_script->value,
107107
redeem_script->value_len, 0);
108108
u8 *final_scriptsig =
109-
bitcoin_scriptsig_redeem(NULL,
109+
bitcoin_scriptsig_redeem(ctx,
110110
take(redeemscript));
111+
tal_wally_start();
111112
wally_psbt_input_set_final_scriptsig(in, final_scriptsig, tal_bytelen(final_scriptsig));
112-
wally_psbt_input_set_redeem_script(in, tal_arr(NULL, u8, 0), 0);
113+
wally_psbt_input_set_redeem_script(in, tal_arr(in, u8, 0), 0);
114+
tal_wally_end(ctx);
113115
}
114116
}
115117

0 commit comments

Comments
 (0)