@@ -616,11 +616,6 @@ pub(super) enum ChannelMonitorUpdateStep {
616
616
idx : u64 ,
617
617
secret : [ u8 ; 32 ] ,
618
618
} ,
619
- /// Indicates our channel is likely a stale version, we're closing, but this update should
620
- /// allow us to spend what is ours if our counterparty broadcasts their latest state.
621
- RescueRemoteCommitmentTXInfo {
622
- their_current_per_commitment_point : PublicKey ,
623
- } ,
624
619
}
625
620
626
621
impl Writeable for ChannelMonitorUpdateStep {
@@ -658,10 +653,6 @@ impl Writeable for ChannelMonitorUpdateStep {
658
653
idx. write ( w) ?;
659
654
secret. write ( w) ?;
660
655
} ,
661
- & ChannelMonitorUpdateStep :: RescueRemoteCommitmentTXInfo { ref their_current_per_commitment_point } => {
662
- 4u8 . write ( w) ?;
663
- their_current_per_commitment_point. write ( w) ?;
664
- } ,
665
656
}
666
657
Ok ( ( ) )
667
658
}
@@ -710,11 +701,6 @@ impl Readable for ChannelMonitorUpdateStep {
710
701
secret : Readable :: read ( r) ?,
711
702
} )
712
703
} ,
713
- 4u8 => {
714
- Ok ( ChannelMonitorUpdateStep :: RescueRemoteCommitmentTXInfo {
715
- their_current_per_commitment_point : Readable :: read ( r) ?,
716
- } )
717
- } ,
718
704
_ => Err ( DecodeError :: InvalidValue ) ,
719
705
}
720
706
}
@@ -775,11 +761,6 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
775
761
pending_htlcs_updated : Vec < HTLCUpdate > ,
776
762
pending_events : Vec < events:: Event > ,
777
763
778
- // Thanks to data loss protection, we may be able to claim our non-htlc funds
779
- // back, this is the script we have to spend from but we need to
780
- // scan every commitment transaction for that
781
- to_remote_rescue : Option < ( Script , SecretKey ) > ,
782
-
783
764
// Used to track onchain events, i.e transactions parts of channels confirmed on chain, on which
784
765
// we have to take actions once they reach enough confs. Key is a block height timer, i.e we enforce
785
766
// actions when we receive a block with given height. Actions depend on OnchainEvent type.
@@ -831,7 +812,6 @@ impl<ChanSigner: ChannelKeys> PartialEq for ChannelMonitor<ChanSigner> {
831
812
self . payment_preimages != other. payment_preimages ||
832
813
self . pending_htlcs_updated != other. pending_htlcs_updated ||
833
814
self . pending_events . len ( ) != other. pending_events . len ( ) || // We trust events to round-trip properly
834
- self . to_remote_rescue != other. to_remote_rescue ||
835
815
self . onchain_events_waiting_threshold_conf != other. onchain_events_waiting_threshold_conf ||
836
816
self . outputs_to_watch != other. outputs_to_watch
837
817
{
@@ -1009,13 +989,6 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
1009
989
}
1010
990
1011
991
self . last_block_hash . write ( writer) ?;
1012
- if let Some ( ( ref to_remote_script, ref local_key) ) = self . to_remote_rescue {
1013
- writer. write_all ( & [ 1 ; 1 ] ) ?;
1014
- to_remote_script. write ( writer) ?;
1015
- local_key. write ( writer) ?;
1016
- } else {
1017
- writer. write_all ( & [ 0 ; 1 ] ) ?;
1018
- }
1019
992
1020
993
writer. write_all ( & byte_utils:: be64_to_array ( self . onchain_events_waiting_threshold_conf . len ( ) as u64 ) ) ?;
1021
994
for ( ref target, ref events) in self . onchain_events_waiting_threshold_conf . iter ( ) {
@@ -1120,8 +1093,6 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1120
1093
pending_htlcs_updated : Vec :: new ( ) ,
1121
1094
pending_events : Vec :: new ( ) ,
1122
1095
1123
- to_remote_rescue : None ,
1124
-
1125
1096
onchain_events_waiting_threshold_conf : HashMap :: new ( ) ,
1126
1097
outputs_to_watch : HashMap :: new ( ) ,
1127
1098
@@ -1229,22 +1200,6 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1229
1200
}
1230
1201
}
1231
1202
1232
- pub ( super ) fn provide_rescue_remote_commitment_tx_info ( & mut self , their_revocation_point : PublicKey ) {
1233
- match self . key_storage {
1234
- Storage :: Local { ref payment_base_key, ref keys, .. } => {
1235
- if let Ok ( payment_key) = chan_utils:: derive_public_key ( & self . secp_ctx , & their_revocation_point, & keys. pubkeys ( ) . payment_basepoint ) {
1236
- let to_remote_script = Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 )
1237
- . push_slice ( & Hash160 :: hash ( & payment_key. serialize ( ) ) [ ..] )
1238
- . into_script ( ) ;
1239
- if let Ok ( to_remote_key) = chan_utils:: derive_private_key ( & self . secp_ctx , & their_revocation_point, & payment_base_key) {
1240
- self . to_remote_rescue = Some ( ( to_remote_script, to_remote_key) ) ;
1241
- }
1242
- }
1243
- } ,
1244
- Storage :: Watchtower { .. } => { }
1245
- }
1246
- }
1247
-
1248
1203
/// Informs this monitor of the latest local (ie broadcastable) commitment transaction. The
1249
1204
/// monitor watches for timeouts and may broadcast it if we approach such a timeout. Thus, it
1250
1205
/// is important that any clones of this channel monitor (including remote clones) by kept
@@ -1287,8 +1242,6 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1287
1242
self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage) ,
1288
1243
ChannelMonitorUpdateStep :: CommitmentSecret { idx, secret } =>
1289
1244
self . provide_secret ( idx, secret) ?,
1290
- ChannelMonitorUpdateStep :: RescueRemoteCommitmentTXInfo { their_current_per_commitment_point } =>
1291
- self . provide_rescue_remote_commitment_tx_info ( their_current_per_commitment_point) ,
1292
1245
}
1293
1246
}
1294
1247
self . latest_update_id = updates. update_id ;
@@ -1313,8 +1266,6 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1313
1266
self . provide_payment_preimage ( & PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 [ ..] ) . into_inner ( ) ) , & payment_preimage) ,
1314
1267
ChannelMonitorUpdateStep :: CommitmentSecret { idx, secret } =>
1315
1268
self . provide_secret ( idx, secret) ?,
1316
- ChannelMonitorUpdateStep :: RescueRemoteCommitmentTXInfo { their_current_per_commitment_point } =>
1317
- self . provide_rescue_remote_commitment_tx_info ( their_current_per_commitment_point) ,
1318
1269
}
1319
1270
}
1320
1271
self . latest_update_id = updates. update_id ;
@@ -1436,7 +1387,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1436
1387
( ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, & per_commitment_point, & keys. pubkeys( ) . revocation_basepoint) ) ,
1437
1388
ignore_error ! ( chan_utils:: derive_private_revocation_key( & self . secp_ctx, & per_commitment_key, & revocation_base_key) ) ,
1438
1389
ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, & per_commitment_point, & keys. pubkeys( ) . htlc_basepoint) ) ,
1439
- Some ( ignore_error ! ( chan_utils :: derive_private_key ( & self . secp_ctx , & per_commitment_point , & payment_base_key) ) ) )
1390
+ Some ( payment_base_key) )
1440
1391
} ,
1441
1392
Storage :: Watchtower { .. } => {
1442
1393
unimplemented ! ( )
@@ -1466,7 +1417,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1466
1417
} else if Some ( & outp. script_pubkey ) == local_payment_p2wpkh. as_ref ( ) {
1467
1418
spendable_outputs. push ( SpendableOutputDescriptor :: DynamicOutputP2WPKH {
1468
1419
outpoint : BitcoinOutPoint { txid : commitment_txid, vout : idx as u32 } ,
1469
- key : local_payment_key. unwrap ( ) ,
1420
+ key : local_payment_key. unwrap ( ) . clone ( ) ,
1470
1421
output : outp. clone ( ) ,
1471
1422
} ) ;
1472
1423
}
@@ -1620,13 +1571,11 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1620
1571
if outp. script_pubkey . is_v0_p2wpkh ( ) {
1621
1572
match self . key_storage {
1622
1573
Storage :: Local { ref payment_base_key, .. } => {
1623
- if let Ok ( local_key) = chan_utils:: derive_private_key ( & self . secp_ctx , & revocation_point, & payment_base_key) {
1624
- spendable_outputs. push ( SpendableOutputDescriptor :: DynamicOutputP2WPKH {
1625
- outpoint : BitcoinOutPoint { txid : commitment_txid, vout : idx as u32 } ,
1626
- key : local_key,
1627
- output : outp. clone ( ) ,
1628
- } ) ;
1629
- }
1574
+ spendable_outputs. push ( SpendableOutputDescriptor :: DynamicOutputP2WPKH {
1575
+ outpoint : BitcoinOutPoint { txid : commitment_txid, vout : idx as u32 } ,
1576
+ key : payment_base_key. clone ( ) ,
1577
+ output : outp. clone ( ) ,
1578
+ } ) ;
1630
1579
} ,
1631
1580
Storage :: Watchtower { .. } => { }
1632
1581
}
@@ -1653,15 +1602,24 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1653
1602
}
1654
1603
}
1655
1604
}
1656
- } else if let Some ( ( ref to_remote_rescue, ref local_key) ) = self . to_remote_rescue {
1657
- for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
1658
- if to_remote_rescue == & outp. script_pubkey {
1659
- spendable_outputs. push ( SpendableOutputDescriptor :: DynamicOutputP2WPKH {
1660
- outpoint : BitcoinOutPoint { txid : commitment_txid, vout : idx as u32 } ,
1661
- key : local_key. clone ( ) ,
1662
- output : outp. clone ( ) ,
1663
- } ) ;
1664
- }
1605
+ } else {
1606
+ match self . key_storage {
1607
+ Storage :: Local { ref payment_base_key, .. } => {
1608
+ let payment_hash160 = Hash160 :: hash ( & PublicKey :: from_secret_key ( & self . secp_ctx , & payment_base_key) . serialize ( ) ) ;
1609
+ let our_payment_script = Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 )
1610
+ . push_slice ( & payment_hash160)
1611
+ . into_script ( ) ;
1612
+ for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
1613
+ if our_payment_script == outp. script_pubkey {
1614
+ spendable_outputs. push ( SpendableOutputDescriptor :: DynamicOutputP2WPKH {
1615
+ outpoint : BitcoinOutPoint { txid : commitment_txid, vout : idx as u32 } ,
1616
+ key : payment_base_key. clone ( ) ,
1617
+ output : outp. clone ( ) ,
1618
+ } ) ;
1619
+ }
1620
+ }
1621
+ } ,
1622
+ Storage :: Watchtower { .. } => unimplemented ! ( ) ,
1665
1623
}
1666
1624
}
1667
1625
( claimable_outpoints, ( commitment_txid, watch_outputs) , spendable_outputs)
@@ -2524,15 +2482,6 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (Sha256dH
2524
2482
}
2525
2483
2526
2484
let last_block_hash: Sha256dHash = Readable :: read ( reader) ?;
2527
- let to_remote_rescue = match <u8 as Readable >:: read ( reader) ? {
2528
- 0 => None ,
2529
- 1 => {
2530
- let to_remote_script = Readable :: read ( reader) ?;
2531
- let local_key = Readable :: read ( reader) ?;
2532
- Some ( ( to_remote_script, local_key) )
2533
- }
2534
- _ => return Err ( DecodeError :: InvalidValue ) ,
2535
- } ;
2536
2485
2537
2486
let waiting_threshold_conf_len: u64 = Readable :: read ( reader) ?;
2538
2487
let mut onchain_events_waiting_threshold_conf = HashMap :: with_capacity ( cmp:: min ( waiting_threshold_conf_len as usize , MAX_ALLOC_SIZE / 128 ) ) ;
@@ -2598,8 +2547,6 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (Sha256dH
2598
2547
pending_htlcs_updated,
2599
2548
pending_events,
2600
2549
2601
- to_remote_rescue,
2602
-
2603
2550
onchain_events_waiting_threshold_conf,
2604
2551
outputs_to_watch,
2605
2552
@@ -2652,7 +2599,6 @@ mod tests {
2652
2599
a_htlc_key: dummy_key. clone( ) ,
2653
2600
b_htlc_key: dummy_key. clone( ) ,
2654
2601
a_delayed_payment_key: dummy_key. clone( ) ,
2655
- b_payment_key: dummy_key. clone( ) ,
2656
2602
}
2657
2603
}
2658
2604
}
0 commit comments