@@ -3992,6 +3992,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
3992
3992
char * error ;
3993
3993
u32 chan_output_index , splice_funding_index ;
3994
3994
struct wally_psbt_output * new_chan_output ;
3995
+ struct wally_psbt * psbt ;
3995
3996
struct inflight * new_inflight ;
3996
3997
struct bitcoin_txid current_psbt_txid ;
3997
3998
struct amount_sat both_amount ;
@@ -4003,7 +4004,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
4003
4004
/* We must loading the funding tx as our previous utxo */
4004
4005
prev_tx = bitcoin_tx_from_txid (peer , peer -> channel -> funding .txid );
4005
4006
4006
- ictx = new_interactivetx_context (tmpctx , our_role ,
4007
+ ictx = new_interactivetx_context (NULL , our_role ,
4007
4008
peer -> pps , peer -> channel_id );
4008
4009
4009
4010
ictx -> next_update_fn = next_splice_step ;
@@ -4015,60 +4016,82 @@ static void splice_initiator_user_finalized(struct peer *peer)
4015
4016
ictx -> tx_add_input_count = peer -> splicing -> tx_add_input_count ;
4016
4017
ictx -> tx_add_output_count = peer -> splicing -> tx_add_output_count ;
4017
4018
4019
+ clone_psbt (NULL , ictx -> current_psbt );
4020
+
4018
4021
ictx -> shared_outpoint = tal (ictx , struct bitcoin_outpoint );
4019
4022
* ictx -> shared_outpoint = peer -> channel -> funding ;
4020
4023
ictx -> funding_tx = prev_tx ;
4021
4024
4022
- error = process_interactivetx_updates (tmpctx , ictx ,
4025
+ clone_psbt (NULL , ictx -> current_psbt );
4026
+
4027
+ error = process_interactivetx_updates (ictx , ictx ,
4023
4028
& peer -> splicing -> received_tx_complete ,
4024
4029
& abort_msg );
4025
4030
if (error )
4026
4031
peer_failed_warn (peer -> pps , & peer -> channel_id ,
4027
4032
"Splice interactivetx error: %s" , error );
4028
4033
4034
+ clone_psbt (NULL , ictx -> current_psbt );
4035
+
4029
4036
check_tx_abort (peer , abort_msg );
4030
4037
4038
+ psbt = ictx -> current_psbt ;
4039
+
4040
+ clone_psbt (NULL , psbt );
4041
+
4031
4042
/* With pause_when_complete fase, this assert should never fail */
4032
4043
assert (peer -> splicing -> received_tx_complete );
4033
4044
peer -> splicing -> sent_tx_complete = true;
4034
4045
4035
- psbt_sort_by_serial_id ( ictx -> current_psbt );
4046
+ clone_psbt ( NULL , psbt );
4036
4047
4037
- new_chan_output = find_channel_output (peer , ictx -> current_psbt ,
4048
+ new_chan_output = find_channel_output (peer , psbt ,
4038
4049
& chan_output_index ,
4039
4050
& peer -> splicing -> remote_funding_pubkey );
4051
+
4052
+ clone_psbt (NULL , psbt );
4040
4053
4041
- splice_funding_index = find_channel_funding_input (ictx -> current_psbt ,
4054
+ splice_funding_index = find_channel_funding_input (psbt ,
4042
4055
& peer -> channel -> funding );
4056
+
4057
+ clone_psbt (NULL , psbt );
4043
4058
4044
- both_amount = check_balances (peer , our_role , ictx -> current_psbt ,
4059
+ both_amount = check_balances (peer , our_role , psbt ,
4045
4060
chan_output_index , splice_funding_index );
4046
4061
new_chan_output -> amount = both_amount .satoshis ; /* Raw: type conv */
4062
+
4063
+ clone_psbt (NULL , psbt );
4047
4064
4048
- psbt_elements_normalize_fees (ictx -> current_psbt );
4065
+ psbt_elements_normalize_fees (psbt );
4066
+
4067
+ clone_psbt (NULL , psbt );
4049
4068
4050
4069
status_debug ("Splice adding inflight: %s" ,
4051
- fmt_wally_psbt (tmpctx , ictx -> current_psbt ));
4070
+ fmt_wally_psbt (tmpctx , psbt ));
4052
4071
4053
- psbt_txid (tmpctx , ictx -> current_psbt , & current_psbt_txid , NULL );
4072
+ psbt_txid (ictx , psbt , & current_psbt_txid , NULL );
4073
+
4074
+ clone_psbt (NULL , psbt );
4054
4075
4055
- outmsg = towire_channeld_add_inflight (tmpctx ,
4076
+ outmsg = towire_channeld_add_inflight (NULL ,
4056
4077
& peer -> splicing -> remote_funding_pubkey ,
4057
4078
& current_psbt_txid ,
4058
4079
chan_output_index ,
4059
4080
peer -> splicing -> feerate_per_kw ,
4060
4081
amount_sat (new_chan_output -> amount ),
4061
4082
peer -> splicing -> opener_relative ,
4062
- ictx -> current_psbt ,
4083
+ psbt ,
4063
4084
true,
4064
4085
peer -> splicing -> force_sign_first );
4086
+
4087
+ clone_psbt (NULL , psbt );
4065
4088
4066
4089
master_wait_sync_reply (tmpctx , peer , take (outmsg ),
4067
4090
WIRE_CHANNELD_GOT_INFLIGHT );
4068
4091
4069
4092
new_inflight = inflights_new (peer );
4070
4093
4071
- psbt_txid (tmpctx , ictx -> current_psbt , & new_inflight -> outpoint .txid ,
4094
+ psbt_txid (new_inflight , psbt , & new_inflight -> outpoint .txid ,
4072
4095
NULL );
4073
4096
new_inflight -> remote_funding = peer -> splicing -> remote_funding_pubkey ;
4074
4097
new_inflight -> outpoint .n = chan_output_index ;
@@ -4084,7 +4107,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
4084
4107
* normal in-memory copy of the psbt: peer->splicing/ictx->current_psbt.
4085
4108
* Since we have to support using the inflight psbt anyway, we default
4086
4109
* to it. */
4087
- new_inflight -> psbt = clone_psbt (new_inflight , ictx -> current_psbt );
4110
+ new_inflight -> psbt = clone_psbt (new_inflight , psbt ); // wally_psbt_clone_alloc fails here
4088
4111
4089
4112
current_push_val = relative_splice_balance_fundee (peer , our_role ,
4090
4113
new_inflight -> psbt ,
@@ -4121,6 +4144,8 @@ static void splice_initiator_user_finalized(struct peer *peer)
4121
4144
true,
4122
4145
!sign_first );
4123
4146
wire_sync_write (MASTER_FD , take (outmsg ));
4147
+
4148
+ tal_free (ictx );
4124
4149
}
4125
4150
4126
4151
/* During a splice the user may call splice_update mulitple times adding
@@ -4141,7 +4166,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
4141
4166
return ;
4142
4167
}
4143
4168
4144
- ictx = new_interactivetx_context (tmpctx , TX_INITIATOR ,
4169
+ ictx = new_interactivetx_context (NULL , TX_INITIATOR ,
4145
4170
peer -> pps , peer -> channel_id );
4146
4171
4147
4172
if (!fromwire_channeld_splice_update (ictx , inmsg , & ictx -> desired_psbt ))
@@ -4152,6 +4177,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
4152
4177
" splice when not in"
4153
4178
" splice mode." );
4154
4179
wire_sync_write (MASTER_FD , take (msg ));
4180
+ tal_free (ictx );
4155
4181
return ;
4156
4182
4157
4183
}
@@ -4175,10 +4201,11 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
4175
4201
if (!interactivetx_has_changes (ictx , ictx -> desired_psbt )) {
4176
4202
splice_initiator_user_finalized (peer );
4177
4203
tal_steal (last_inflight (peer ), last_inflight (peer )-> psbt );
4204
+ tal_free (ictx );
4178
4205
return ;
4179
4206
}
4180
4207
4181
- error = process_interactivetx_updates (tmpctx , ictx ,
4208
+ error = process_interactivetx_updates (ictx , ictx ,
4182
4209
& peer -> splicing -> received_tx_complete ,
4183
4210
& abort_msg );
4184
4211
if (error )
@@ -4199,6 +4226,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
4199
4226
ictx -> current_psbt ,
4200
4227
false, false);
4201
4228
wire_sync_write (MASTER_FD , take (outmsg ));
4229
+ tal_free (ictx );
4202
4230
}
4203
4231
4204
4232
/* This occurs when the user has signed the final version of the PSBT. At this
0 commit comments