File tree 3 files changed +13
-15
lines changed
3 files changed +13
-15
lines changed Original file line number Diff line number Diff line change @@ -2855,7 +2855,6 @@ pub fn finalize_unilateral_close_settled_channel<S: Deref>(
2855
2855
destination_address : & Address ,
2856
2856
fee_rate_per_vb : u64 ,
2857
2857
signer : & S ,
2858
- is_offer : bool ,
2859
2858
is_initiator : bool ,
2860
2859
) -> Result < ( Transaction , Channel ) , Error >
2861
2860
where
@@ -2892,7 +2891,6 @@ where
2892
2891
CET_NSEQUENCE ,
2893
2892
0 ,
2894
2893
fee_rate_per_vb,
2895
- is_offer,
2896
2894
) ?;
2897
2895
2898
2896
let closing_channel = SettledClosingChannel {
Original file line number Diff line number Diff line change @@ -1298,11 +1298,10 @@ where
1298
1298
& self ,
1299
1299
signed_channel : SignedChannel ,
1300
1300
) -> Result < ( ) , Error > {
1301
- let ( settle_tx, & is_offer , & is_initiator) = get_signed_channel_state ! (
1301
+ let ( settle_tx, & is_initiator) = get_signed_channel_state ! (
1302
1302
signed_channel,
1303
1303
SettledClosing ,
1304
1304
settle_transaction,
1305
- is_offer,
1306
1305
is_initiator
1307
1306
) ?;
1308
1307
@@ -1312,11 +1311,9 @@ where
1312
1311
>= CET_NSEQUENCE
1313
1312
{
1314
1313
log:: info!(
1315
- "Settle transaction {} for channel {} has enough confirmations to spend from it. is_offer={}, is_initiator={} " ,
1314
+ "Settle transaction {} for channel {} has enough confirmations to spend from it" ,
1316
1315
settle_tx. txid( ) ,
1317
1316
serialize_hex( & signed_channel. channel_id) ,
1318
- is_offer,
1319
- is_initiator
1320
1317
) ;
1321
1318
1322
1319
let fee_rate_per_vb: u64 = {
@@ -1338,7 +1335,6 @@ where
1338
1335
& self . wallet . get_new_address ( ) ?,
1339
1336
fee_rate_per_vb,
1340
1337
& self . wallet ,
1341
- is_offer,
1342
1338
is_initiator,
1343
1339
) ?;
1344
1340
Original file line number Diff line number Diff line change @@ -415,27 +415,31 @@ pub fn create_and_sign_claim_settle_transaction<C: Signing>(
415
415
csv_timelock : u32 ,
416
416
lock_time : u32 ,
417
417
fee_rate_per_vb : u64 ,
418
- is_offer : bool ,
419
418
) -> Result < Transaction , Error > {
420
419
let own_descriptor = settle_descriptor ( own_params, & counter_params. own_pk , csv_timelock) ;
421
420
422
- let vout = if is_offer {
423
- 0
424
- } else {
425
- 1
421
+ let output = settle_tx. output . iter ( ) . enumerate ( ) . find ( |( _, output) | {
422
+ output. script_pubkey == own_descriptor. script_pubkey ( )
423
+ } ) ;
424
+
425
+ let ( vout, output) = match output {
426
+ Some ( ( vout, output) ) => ( vout, output) ,
427
+ None => {
428
+ return Err ( Error :: InvalidArgument ( "No claimable output found on settle transaction" . to_string ( ) ) ) ;
429
+ } ,
426
430
} ;
427
431
428
432
let tx_in = TxIn {
429
433
previous_output : OutPoint {
430
434
txid : settle_tx. txid ( ) ,
431
- vout,
435
+ vout : vout as u32 ,
432
436
} ,
433
437
sequence : Sequence :: from_height ( csv_timelock as u16 ) ,
434
438
script_sig : Script :: default ( ) ,
435
439
witness : Witness :: default ( ) ,
436
440
} ;
437
441
438
- let input_value = settle_tx . output [ vout as usize ] . value ;
442
+ let input_value = output. value ;
439
443
440
444
let dest_script_pk_len = dest_address. script_pubkey ( ) . len ( ) ;
441
445
let var_int_prefix_len = crate :: util:: compute_var_int_prefix_size ( dest_script_pk_len) ;
You can’t perform that action at this time.
0 commit comments