@@ -3610,8 +3610,9 @@ static void resume_splice_negotiation(struct peer *peer,
3610
3610
" Most likely you are missing"
3611
3611
" signatures." );
3612
3612
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 );
3615
3616
}
3616
3617
3617
3618
final_tx = bitcoin_tx_with_psbt (tmpctx , current_psbt );
@@ -3654,6 +3655,13 @@ static void resume_splice_negotiation(struct peer *peer,
3654
3655
new_output_index );
3655
3656
wire_sync_write (MASTER_FD , take (msg ));
3656
3657
}
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 );
3657
3665
}
3658
3666
3659
3667
static struct inflight * inflights_new (struct peer * peer )
@@ -3841,7 +3849,7 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
3841
3849
funding_feerate_perkw ,
3842
3850
both_amount ,
3843
3851
peer -> splicing -> accepter_relative ,
3844
- ictx -> current_psbt ,
3852
+ clone_psbt ( tmpctx , ictx -> current_psbt ) ,
3845
3853
false,
3846
3854
peer -> splicing -> force_sign_first );
3847
3855
@@ -3862,15 +3870,33 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
3862
3870
new_inflight -> force_sign_first = peer -> splicing -> force_sign_first ;
3863
3871
new_inflight -> is_locked = false;
3864
3872
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 ,
3866
3877
outpoint .n , splice_funding_index );
3878
+
3879
+ psbt_get_bytes (NULL , new_inflight -> psbt , & dummy );
3880
+
3867
3881
update_hsmd_with_splice (peer , new_inflight , our_role , current_push_val );
3868
3882
3883
+ psbt_get_bytes (NULL , new_inflight -> psbt , & dummy );
3884
+
3869
3885
update_view_from_inflights (peer );
3870
3886
3887
+ psbt_get_bytes (NULL , new_inflight -> psbt , & dummy );
3888
+
3871
3889
peer -> splice_state -> count ++ ;
3872
3890
3891
+ psbt_get_bytes (NULL , new_inflight -> psbt , & dummy );
3892
+
3873
3893
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 );
3874
3900
}
3875
3901
3876
3902
/* 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)
3992
4018
char * error ;
3993
4019
u32 chan_output_index , splice_funding_index ;
3994
4020
struct wally_psbt_output * new_chan_output ;
4021
+ struct wally_psbt * psbt ;
3995
4022
struct inflight * new_inflight ;
3996
4023
struct bitcoin_txid current_psbt_txid ;
3997
4024
struct amount_sat both_amount ;
@@ -4003,7 +4030,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
4003
4030
/* We must loading the funding tx as our previous utxo */
4004
4031
prev_tx = bitcoin_tx_from_txid (peer , peer -> channel -> funding .txid );
4005
4032
4006
- ictx = new_interactivetx_context (tmpctx , our_role ,
4033
+ ictx = new_interactivetx_context (NULL , our_role ,
4007
4034
peer -> pps , peer -> channel_id );
4008
4035
4009
4036
ictx -> next_update_fn = next_splice_step ;
@@ -4015,60 +4042,82 @@ static void splice_initiator_user_finalized(struct peer *peer)
4015
4042
ictx -> tx_add_input_count = peer -> splicing -> tx_add_input_count ;
4016
4043
ictx -> tx_add_output_count = peer -> splicing -> tx_add_output_count ;
4017
4044
4045
+ clone_psbt (NULL , ictx -> current_psbt );
4046
+
4018
4047
ictx -> shared_outpoint = tal (ictx , struct bitcoin_outpoint );
4019
4048
* ictx -> shared_outpoint = peer -> channel -> funding ;
4020
4049
ictx -> funding_tx = prev_tx ;
4021
4050
4022
- error = process_interactivetx_updates (tmpctx , ictx ,
4051
+ clone_psbt (NULL , ictx -> current_psbt );
4052
+
4053
+ error = process_interactivetx_updates (ictx , ictx ,
4023
4054
& peer -> splicing -> received_tx_complete ,
4024
4055
& abort_msg );
4025
4056
if (error )
4026
4057
peer_failed_warn (peer -> pps , & peer -> channel_id ,
4027
4058
"Splice interactivetx error: %s" , error );
4028
4059
4060
+ clone_psbt (NULL , ictx -> current_psbt ); // dustin
4061
+
4029
4062
check_tx_abort (peer , abort_msg );
4030
4063
4064
+ psbt = ictx -> current_psbt ;
4065
+
4066
+ clone_psbt (NULL , psbt );
4067
+
4031
4068
/* With pause_when_complete fase, this assert should never fail */
4032
4069
assert (peer -> splicing -> received_tx_complete );
4033
4070
peer -> splicing -> sent_tx_complete = true;
4034
4071
4035
- psbt_sort_by_serial_id ( ictx -> current_psbt );
4072
+ clone_psbt ( NULL , psbt );
4036
4073
4037
- new_chan_output = find_channel_output (peer , ictx -> current_psbt ,
4074
+ new_chan_output = find_channel_output (peer , psbt ,
4038
4075
& chan_output_index ,
4039
4076
& peer -> splicing -> remote_funding_pubkey );
4077
+
4078
+ clone_psbt (NULL , psbt );
4040
4079
4041
- splice_funding_index = find_channel_funding_input (ictx -> current_psbt ,
4080
+ splice_funding_index = find_channel_funding_input (psbt ,
4042
4081
& peer -> channel -> funding );
4082
+
4083
+ clone_psbt (NULL , psbt ); // lisa
4043
4084
4044
- both_amount = check_balances (peer , our_role , ictx -> current_psbt ,
4085
+ both_amount = check_balances (peer , our_role , psbt ,
4045
4086
chan_output_index , splice_funding_index );
4046
4087
new_chan_output -> amount = both_amount .satoshis ; /* Raw: type conv */
4088
+
4089
+ clone_psbt (NULL , psbt );
4047
4090
4048
- psbt_elements_normalize_fees (ictx -> current_psbt );
4091
+ psbt_elements_normalize_fees (psbt );
4092
+
4093
+ clone_psbt (NULL , psbt );
4049
4094
4050
4095
status_debug ("Splice adding inflight: %s" ,
4051
- fmt_wally_psbt (tmpctx , ictx -> current_psbt ));
4096
+ fmt_wally_psbt (tmpctx , psbt ));
4052
4097
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 );
4054
4101
4055
- outmsg = towire_channeld_add_inflight (tmpctx ,
4102
+ outmsg = towire_channeld_add_inflight (NULL ,
4056
4103
& peer -> splicing -> remote_funding_pubkey ,
4057
4104
& current_psbt_txid ,
4058
4105
chan_output_index ,
4059
4106
peer -> splicing -> feerate_per_kw ,
4060
4107
amount_sat (new_chan_output -> amount ),
4061
4108
peer -> splicing -> opener_relative ,
4062
- ictx -> current_psbt ,
4109
+ psbt ,
4063
4110
true,
4064
4111
peer -> splicing -> force_sign_first );
4112
+
4113
+ clone_psbt (NULL , psbt );
4065
4114
4066
4115
master_wait_sync_reply (tmpctx , peer , take (outmsg ),
4067
4116
WIRE_CHANNELD_GOT_INFLIGHT );
4068
4117
4069
4118
new_inflight = inflights_new (peer );
4070
4119
4071
- psbt_txid (tmpctx , ictx -> current_psbt , & new_inflight -> outpoint .txid ,
4120
+ psbt_txid (new_inflight , psbt , & new_inflight -> outpoint .txid ,
4072
4121
NULL );
4073
4122
new_inflight -> remote_funding = peer -> splicing -> remote_funding_pubkey ;
4074
4123
new_inflight -> outpoint .n = chan_output_index ;
@@ -4084,7 +4133,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
4084
4133
* normal in-memory copy of the psbt: peer->splicing/ictx->current_psbt.
4085
4134
* Since we have to support using the inflight psbt anyway, we default
4086
4135
* to it. */
4087
- new_inflight -> psbt = clone_psbt (new_inflight , ictx -> current_psbt );
4136
+ new_inflight -> psbt = clone_psbt (new_inflight , psbt );
4088
4137
4089
4138
current_push_val = relative_splice_balance_fundee (peer , our_role ,
4090
4139
new_inflight -> psbt ,
@@ -4113,14 +4162,23 @@ static void splice_initiator_user_finalized(struct peer *peer)
4113
4162
sign_first = do_i_sign_first (peer , new_inflight -> psbt , our_role ,
4114
4163
peer -> splicing -> force_sign_first );
4115
4164
4165
+ assert (new_inflight -> psbt );
4166
+
4116
4167
if (!sign_first )
4117
4168
resume_splice_negotiation (peer , false, false, false, true);
4118
4169
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
+
4119
4175
outmsg = towire_channeld_splice_confirmed_update (NULL ,
4120
4176
new_inflight -> psbt ,
4121
4177
true,
4122
4178
!sign_first );
4123
4179
wire_sync_write (MASTER_FD , take (outmsg ));
4180
+
4181
+ tal_free (ictx );
4124
4182
}
4125
4183
4126
4184
/* 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)
4141
4199
return ;
4142
4200
}
4143
4201
4144
- ictx = new_interactivetx_context (tmpctx , TX_INITIATOR ,
4202
+ ictx = new_interactivetx_context (NULL , TX_INITIATOR ,
4145
4203
peer -> pps , peer -> channel_id );
4146
4204
4147
4205
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)
4152
4210
" splice when not in"
4153
4211
" splice mode." );
4154
4212
wire_sync_write (MASTER_FD , take (msg ));
4213
+ tal_free (ictx );
4155
4214
return ;
4156
4215
4157
4216
}
@@ -4177,10 +4236,11 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
4177
4236
if (!interactivetx_has_changes (ictx , ictx -> desired_psbt )) {
4178
4237
splice_initiator_user_finalized (peer );
4179
4238
tal_steal (last_inflight (peer ), last_inflight (peer )-> psbt );
4239
+ tal_free (ictx );
4180
4240
return ;
4181
4241
}
4182
4242
4183
- error = process_interactivetx_updates (tmpctx , ictx ,
4243
+ error = process_interactivetx_updates (ictx , ictx ,
4184
4244
& peer -> splicing -> received_tx_complete ,
4185
4245
& abort_msg );
4186
4246
if (error )
@@ -4201,9 +4261,10 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
4201
4261
4202
4262
/* Peer may have modified our PSBT so we return it to the user here */
4203
4263
outmsg = towire_channeld_splice_confirmed_update (NULL ,
4204
- ictx -> current_psbt ,
4264
+ peer -> splicing -> current_psbt ,
4205
4265
false, false);
4206
4266
wire_sync_write (MASTER_FD , take (outmsg ));
4267
+ tal_free (ictx );
4207
4268
}
4208
4269
4209
4270
/* 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)
5650
5711
5651
5712
for (size_t i = 0 ; i < tal_count (peer -> splice_state -> inflights ); i ++ ) {
5652
5713
struct inflight * inflight = peer -> splice_state -> inflights [i ];
5714
+ size_t dummy ;
5715
+ psbt_get_bytes (NULL , inflight -> psbt , & dummy );
5653
5716
if (bitcoin_txid_eq (& inflight -> outpoint .txid ,
5654
5717
& txid )) {
5655
5718
inflight -> is_locked = true;
0 commit comments