Skip to content

Commit 0671654

Browse files
committed
Test commit for CI
1 parent 057982b commit 0671654

File tree

4 files changed

+178
-22
lines changed

4 files changed

+178
-22
lines changed

Diff for: channeld/channeld.c

+83-20
Original file line numberDiff line numberDiff line change
@@ -3610,8 +3610,9 @@ static void resume_splice_negotiation(struct peer *peer,
36103610
" Most likely you are missing"
36113611
" signatures.");
36123612

3613-
psbt_finalize_input(current_psbt, in,
3614-
inws[j++]);
3613+
tal_wally_start();
3614+
psbt_finalize_input(current_psbt, in, inws[j++]);
3615+
tal_wally_end(current_psbt);
36153616
}
36163617

36173618
final_tx = bitcoin_tx_with_psbt(tmpctx, current_psbt);
@@ -3654,6 +3655,13 @@ static void resume_splice_negotiation(struct peer *peer,
36543655
new_output_index);
36553656
wire_sync_write(MASTER_FD, take(msg));
36563657
}
3658+
3659+
size_t dummy;
3660+
psbt_get_bytes(NULL, inflight->psbt, &dummy);
3661+
psbt_get_bytes(NULL, current_psbt, &dummy);
3662+
clone_psbt(NULL, inflight->psbt);
3663+
clone_psbt(NULL, current_psbt);
3664+
assert(inflight->psbt == current_psbt);
36573665
}
36583666

36593667
static struct inflight *inflights_new(struct peer *peer)
@@ -3841,7 +3849,7 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
38413849
funding_feerate_perkw,
38423850
both_amount,
38433851
peer->splicing->accepter_relative,
3844-
ictx->current_psbt,
3852+
clone_psbt(tmpctx, ictx->current_psbt),
38453853
false,
38463854
peer->splicing->force_sign_first);
38473855

@@ -3862,15 +3870,33 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
38623870
new_inflight->force_sign_first = peer->splicing->force_sign_first;
38633871
new_inflight->is_locked = false;
38643872

3865-
current_push_val = relative_splice_balance_fundee(peer, our_role,ictx->current_psbt,
3873+
size_t dummy;
3874+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
3875+
3876+
current_push_val = relative_splice_balance_fundee(peer, our_role, ictx->current_psbt,
38663877
outpoint.n, splice_funding_index);
3878+
3879+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
3880+
38673881
update_hsmd_with_splice(peer, new_inflight, our_role, current_push_val);
38683882

3883+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
3884+
38693885
update_view_from_inflights(peer);
38703886

3887+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
3888+
38713889
peer->splice_state->count++;
38723890

3891+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
3892+
38733893
resume_splice_negotiation(peer, true, true, true, true);
3894+
3895+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
3896+
3897+
clean_tmpctx();
3898+
3899+
psbt_get_bytes(NULL, new_inflight->psbt, &dummy);
38743900
}
38753901

38763902
/* splice_initiator runs when splice_ack is received by the other side. It
@@ -3992,6 +4018,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
39924018
char *error;
39934019
u32 chan_output_index, splice_funding_index;
39944020
struct wally_psbt_output *new_chan_output;
4021+
struct wally_psbt *psbt;
39954022
struct inflight *new_inflight;
39964023
struct bitcoin_txid current_psbt_txid;
39974024
struct amount_sat both_amount;
@@ -4003,7 +4030,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
40034030
/* We must loading the funding tx as our previous utxo */
40044031
prev_tx = bitcoin_tx_from_txid(peer, peer->channel->funding.txid);
40054032

4006-
ictx = new_interactivetx_context(tmpctx, our_role,
4033+
ictx = new_interactivetx_context(NULL, our_role,
40074034
peer->pps, peer->channel_id);
40084035

40094036
ictx->next_update_fn = next_splice_step;
@@ -4015,60 +4042,82 @@ static void splice_initiator_user_finalized(struct peer *peer)
40154042
ictx->tx_add_input_count = peer->splicing->tx_add_input_count;
40164043
ictx->tx_add_output_count = peer->splicing->tx_add_output_count;
40174044

4045+
clone_psbt(NULL, ictx->current_psbt);
4046+
40184047
ictx->shared_outpoint = tal(ictx, struct bitcoin_outpoint);
40194048
*ictx->shared_outpoint = peer->channel->funding;
40204049
ictx->funding_tx = prev_tx;
40214050

4022-
error = process_interactivetx_updates(tmpctx, ictx,
4051+
clone_psbt(NULL, ictx->current_psbt);
4052+
4053+
error = process_interactivetx_updates(ictx, ictx,
40234054
&peer->splicing->received_tx_complete,
40244055
&abort_msg);
40254056
if (error)
40264057
peer_failed_warn(peer->pps, &peer->channel_id,
40274058
"Splice interactivetx error: %s", error);
40284059

4060+
clone_psbt(NULL, ictx->current_psbt); // dustin
4061+
40294062
check_tx_abort(peer, abort_msg);
40304063

4064+
psbt = ictx->current_psbt;
4065+
4066+
clone_psbt(NULL, psbt);
4067+
40314068
/* With pause_when_complete fase, this assert should never fail */
40324069
assert(peer->splicing->received_tx_complete);
40334070
peer->splicing->sent_tx_complete = true;
40344071

4035-
psbt_sort_by_serial_id(ictx->current_psbt);
4072+
clone_psbt(NULL, psbt);
40364073

4037-
new_chan_output = find_channel_output(peer, ictx->current_psbt,
4074+
new_chan_output = find_channel_output(peer, psbt,
40384075
&chan_output_index,
40394076
&peer->splicing->remote_funding_pubkey);
4077+
4078+
clone_psbt(NULL, psbt);
40404079

4041-
splice_funding_index = find_channel_funding_input(ictx->current_psbt,
4080+
splice_funding_index = find_channel_funding_input(psbt,
40424081
&peer->channel->funding);
4082+
4083+
clone_psbt(NULL, psbt); // lisa
40434084

4044-
both_amount = check_balances(peer, our_role, ictx->current_psbt,
4085+
both_amount = check_balances(peer, our_role, psbt,
40454086
chan_output_index, splice_funding_index);
40464087
new_chan_output->amount = both_amount.satoshis; /* Raw: type conv */
4088+
4089+
clone_psbt(NULL, psbt);
40474090

4048-
psbt_elements_normalize_fees(ictx->current_psbt);
4091+
psbt_elements_normalize_fees(psbt);
4092+
4093+
clone_psbt(NULL, psbt);
40494094

40504095
status_debug("Splice adding inflight: %s",
4051-
fmt_wally_psbt(tmpctx, ictx->current_psbt));
4096+
fmt_wally_psbt(tmpctx, psbt));
40524097

4053-
psbt_txid(tmpctx, ictx->current_psbt, &current_psbt_txid, NULL);
4098+
psbt_txid(ictx, psbt, &current_psbt_txid, NULL);
4099+
4100+
clone_psbt(NULL, psbt);
40544101

4055-
outmsg = towire_channeld_add_inflight(tmpctx,
4102+
outmsg = towire_channeld_add_inflight(NULL,
40564103
&peer->splicing->remote_funding_pubkey,
40574104
&current_psbt_txid,
40584105
chan_output_index,
40594106
peer->splicing->feerate_per_kw,
40604107
amount_sat(new_chan_output->amount),
40614108
peer->splicing->opener_relative,
4062-
ictx->current_psbt,
4109+
psbt,
40634110
true,
40644111
peer->splicing->force_sign_first);
4112+
4113+
clone_psbt(NULL, psbt);
40654114

40664115
master_wait_sync_reply(tmpctx, peer, take(outmsg),
40674116
WIRE_CHANNELD_GOT_INFLIGHT);
40684117

40694118
new_inflight = inflights_new(peer);
40704119

4071-
psbt_txid(tmpctx, ictx->current_psbt, &new_inflight->outpoint.txid,
4120+
psbt_txid(new_inflight, psbt, &new_inflight->outpoint.txid,
40724121
NULL);
40734122
new_inflight->remote_funding = peer->splicing->remote_funding_pubkey;
40744123
new_inflight->outpoint.n = chan_output_index;
@@ -4084,7 +4133,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
40844133
* normal in-memory copy of the psbt: peer->splicing/ictx->current_psbt.
40854134
* Since we have to support using the inflight psbt anyway, we default
40864135
* to it. */
4087-
new_inflight->psbt = clone_psbt(new_inflight, ictx->current_psbt);
4136+
new_inflight->psbt = clone_psbt(new_inflight, psbt);
40884137

40894138
current_push_val = relative_splice_balance_fundee(peer, our_role,
40904139
new_inflight->psbt,
@@ -4113,14 +4162,23 @@ static void splice_initiator_user_finalized(struct peer *peer)
41134162
sign_first = do_i_sign_first(peer, new_inflight->psbt, our_role,
41144163
peer->splicing->force_sign_first);
41154164

4165+
assert(new_inflight->psbt);
4166+
41164167
if (!sign_first)
41174168
resume_splice_negotiation(peer, false, false, false, true);
41184169

4170+
assert(new_inflight->psbt);
4171+
struct wally_psbt *old_psbt = new_inflight->psbt;
4172+
new_inflight->psbt = clone_psbt(new_inflight, new_inflight->psbt);
4173+
tal_free(old_psbt);
4174+
41194175
outmsg = towire_channeld_splice_confirmed_update(NULL,
41204176
new_inflight->psbt,
41214177
true,
41224178
!sign_first);
41234179
wire_sync_write(MASTER_FD, take(outmsg));
4180+
4181+
tal_free(ictx);
41244182
}
41254183

41264184
/* During a splice the user may call splice_update mulitple times adding
@@ -4141,7 +4199,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
41414199
return;
41424200
}
41434201

4144-
ictx = new_interactivetx_context(tmpctx, TX_INITIATOR,
4202+
ictx = new_interactivetx_context(NULL, TX_INITIATOR,
41454203
peer->pps, peer->channel_id);
41464204

41474205
if (!fromwire_channeld_splice_update(ictx, inmsg, &ictx->desired_psbt))
@@ -4152,6 +4210,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
41524210
" splice when not in"
41534211
" splice mode.");
41544212
wire_sync_write(MASTER_FD, take(msg));
4213+
tal_free(ictx);
41554214
return;
41564215

41574216
}
@@ -4177,10 +4236,11 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
41774236
if (!interactivetx_has_changes(ictx, ictx->desired_psbt)) {
41784237
splice_initiator_user_finalized(peer);
41794238
tal_steal(last_inflight(peer), last_inflight(peer)->psbt);
4239+
tal_free(ictx);
41804240
return;
41814241
}
41824242

4183-
error = process_interactivetx_updates(tmpctx, ictx,
4243+
error = process_interactivetx_updates(ictx, ictx,
41844244
&peer->splicing->received_tx_complete,
41854245
&abort_msg);
41864246
if (error)
@@ -4201,9 +4261,10 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
42014261

42024262
/* Peer may have modified our PSBT so we return it to the user here */
42034263
outmsg = towire_channeld_splice_confirmed_update(NULL,
4204-
ictx->current_psbt,
4264+
peer->splicing->current_psbt,
42054265
false, false);
42064266
wire_sync_write(MASTER_FD, take(outmsg));
4267+
tal_free(ictx);
42074268
}
42084269

42094270
/* This occurs when the user has signed the final version of the PSBT. At this
@@ -5650,6 +5711,8 @@ static void handle_funding_depth(struct peer *peer, const u8 *msg)
56505711

56515712
for (size_t i = 0; i < tal_count(peer->splice_state->inflights); i++) {
56525713
struct inflight *inflight = peer->splice_state->inflights[i];
5714+
size_t dummy;
5715+
psbt_get_bytes(NULL, inflight->psbt, &dummy);
56535716
if (bitcoin_txid_eq(&inflight->outpoint.txid,
56545717
&txid)) {
56555718
inflight->is_locked = true;

Diff for: common/interactivetx.c

+44-2
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,36 @@ char *process_interactivetx_updates(const tal_t *ctx,
391391
if (received_tx_complete)
392392
they_complete = *received_tx_complete;
393393

394-
/* Build change_set and handle PSBT variables */
395-
ictx->change_set = tal_free(ictx->change_set);
394+
if (ictx->current_psbt)
395+
clone_psbt(NULL, ictx->current_psbt);
396+
if (ictx->desired_psbt)
397+
clone_psbt(NULL, ictx->desired_psbt);
396398

397399
/* Call next_update_fn or default to 'desired_psbt' */
398400
next_psbt = ictx->next_update_fn(ictx, ictx);
399401

402+
if (ictx->current_psbt)
403+
clone_psbt(NULL, ictx->current_psbt);
404+
if (ictx->desired_psbt)
405+
clone_psbt(NULL, ictx->desired_psbt);
406+
400407
/* Returning NULL from next_update_fn is the same as using `current_psbt`
401408
* with no changes -- both indicate no changes */
402409
if (!next_psbt)
403410
next_psbt = ictx->current_psbt;
404411

412+
if (ictx->current_psbt)
413+
clone_psbt(NULL, ictx->current_psbt);
414+
if (ictx->desired_psbt)
415+
clone_psbt(NULL, ictx->desired_psbt);
416+
405417
ictx->change_set = get_changes(ctx, ictx, next_psbt);
406418

419+
if (ictx->current_psbt)
420+
clone_psbt(NULL, ictx->current_psbt); // this fails
421+
if (ictx->desired_psbt)
422+
clone_psbt(NULL, ictx->desired_psbt);
423+
407424
/* If current_psbt and next_psbt are the same, dont double free it!
408425
* Otherwise we advance `current_psbt` to `next_psbt` and begin
409426
* processing the change set in `ictx->change_set` */
@@ -414,6 +431,11 @@ char *process_interactivetx_updates(const tal_t *ctx,
414431
ictx->current_psbt = next_psbt;
415432
}
416433

434+
if (ictx->current_psbt)
435+
clone_psbt(NULL, ictx->current_psbt);
436+
if (ictx->desired_psbt)
437+
clone_psbt(NULL, ictx->desired_psbt);
438+
417439
/* As initiator we always start with a single send to start it off */
418440
if (ictx->our_role == TX_INITIATOR) {
419441
error = send_next(ctx, ictx, &we_complete);
@@ -426,6 +448,11 @@ char *process_interactivetx_updates(const tal_t *ctx,
426448
}
427449
}
428450

451+
if (ictx->current_psbt)
452+
clone_psbt(NULL, ictx->current_psbt);
453+
if (ictx->desired_psbt)
454+
clone_psbt(NULL, ictx->desired_psbt);
455+
429456
/* Loop through tx update turns with peer */
430457
while (!(we_complete && they_complete)) {
431458
struct channel_id cid;
@@ -439,10 +466,20 @@ char *process_interactivetx_updates(const tal_t *ctx,
439466
if (received_tx_complete)
440467
*received_tx_complete = false;
441468

469+
if (ictx->current_psbt)
470+
clone_psbt(NULL, ictx->current_psbt);
471+
if (ictx->desired_psbt)
472+
clone_psbt(NULL, ictx->desired_psbt);
473+
442474
msg = read_next_msg(ctx, ictx, &error);
443475
if (error)
444476
return error;
445477

478+
if (ictx->current_psbt)
479+
clone_psbt(NULL, ictx->current_psbt);
480+
if (ictx->desired_psbt)
481+
clone_psbt(NULL, ictx->desired_psbt);
482+
446483
t = fromwire_peektype(msg);
447484
switch (t) {
448485
case WIRE_TX_ADD_INPUT: {
@@ -803,6 +840,11 @@ char *process_interactivetx_updates(const tal_t *ctx,
803840
send_next(ctx, ictx, &we_complete);
804841
}
805842

843+
if (ictx->current_psbt)
844+
clone_psbt(NULL, ictx->current_psbt);
845+
if (ictx->desired_psbt)
846+
clone_psbt(NULL, ictx->desired_psbt);
847+
806848
/* Sort psbt! */
807849
psbt_sort_by_serial_id(ictx->current_psbt);
808850

0 commit comments

Comments
 (0)