@@ -290,7 +290,7 @@ impl<Key : Send + cmp::Eq + hash::Hash + 'static, ChanSigner: ChannelKeys, T: De
290
290
hash_map:: Entry :: Occupied ( _) => return Err ( MonitorUpdateError ( "Channel monitor for given key is already present" ) ) ,
291
291
hash_map:: Entry :: Vacant ( e) => e,
292
292
} ;
293
- match monitor. onchain_detection . funding_info {
293
+ match monitor. funding_info {
294
294
None => {
295
295
return Err ( MonitorUpdateError ( "Try to update a useless monitor without funding_txo !" ) ) ;
296
296
} ,
@@ -314,7 +314,7 @@ impl<Key : Send + cmp::Eq + hash::Hash + 'static, ChanSigner: ChannelKeys, T: De
314
314
let mut monitors = self . monitors . lock ( ) . unwrap ( ) ;
315
315
match monitors. get_mut ( & key) {
316
316
Some ( orig_monitor) => {
317
- log_trace ! ( self , "Updating Channel Monitor for channel {}" , log_funding_info!( orig_monitor. onchain_detection ) ) ;
317
+ log_trace ! ( self , "Updating Channel Monitor for channel {}" , log_funding_info!( orig_monitor) ) ;
318
318
orig_monitor. update_monitor ( update, & self . broadcaster )
319
319
} ,
320
320
None => Err ( MonitorUpdateError ( "No such monitor registered" ) )
@@ -391,20 +391,6 @@ pub(crate) const LATENCY_GRACE_PERIOD_BLOCKS: u32 = 3;
391
391
/// keeping bumping another claim tx to solve the outpoint.
392
392
pub ( crate ) const ANTI_REORG_DELAY : u32 = 6 ;
393
393
394
- struct OnchainDetection < ChanSigner : ChannelKeys > {
395
- keys : ChanSigner ,
396
- funding_info : Option < ( OutPoint , Script ) > ,
397
- current_remote_commitment_txid : Option < Sha256dHash > ,
398
- prev_remote_commitment_txid : Option < Sha256dHash > ,
399
- }
400
-
401
- #[ cfg( any( test, feature = "fuzztarget" ) ) ]
402
- impl < ChanSigner : ChannelKeys > PartialEq for OnchainDetection < ChanSigner > {
403
- fn eq ( & self , other : & Self ) -> bool {
404
- self . keys . pubkeys ( ) == other. keys . pubkeys ( )
405
- }
406
- }
407
-
408
394
#[ derive( Clone , PartialEq ) ]
409
395
struct LocalSignedTx {
410
396
/// txid of the transaction in tx, just used to make comparison faster
@@ -734,7 +720,11 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
734
720
broadcasted_remote_payment_script : Option < ( Script , SecretKey ) > ,
735
721
shutdown_script : Script ,
736
722
737
- onchain_detection : OnchainDetection < ChanSigner > ,
723
+ keys : ChanSigner ,
724
+ funding_info : Option < ( OutPoint , Script ) > ,
725
+ current_remote_commitment_txid : Option < Sha256dHash > ,
726
+ prev_remote_commitment_txid : Option < Sha256dHash > ,
727
+
738
728
their_htlc_base_key : Option < PublicKey > ,
739
729
their_delayed_payment_base_key : Option < PublicKey > ,
740
730
funding_redeemscript : Option < Script > ,
@@ -817,7 +807,10 @@ impl<ChanSigner: ChannelKeys> PartialEq for ChannelMonitor<ChanSigner> {
817
807
self . destination_script != other. destination_script ||
818
808
self . broadcasted_local_revokable_script != other. broadcasted_local_revokable_script ||
819
809
self . broadcasted_remote_payment_script != other. broadcasted_remote_payment_script ||
820
- self . onchain_detection != other. onchain_detection ||
810
+ self . keys . pubkeys ( ) != other. keys . pubkeys ( ) ||
811
+ self . funding_info != other. funding_info ||
812
+ self . current_remote_commitment_txid != other. current_remote_commitment_txid ||
813
+ self . prev_remote_commitment_txid != other. prev_remote_commitment_txid ||
821
814
self . their_htlc_base_key != other. their_htlc_base_key ||
822
815
self . their_delayed_payment_base_key != other. their_delayed_payment_base_key ||
823
816
self . funding_redeemscript != other. funding_redeemscript ||
@@ -878,8 +871,8 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
878
871
}
879
872
self . shutdown_script . write ( writer) ?;
880
873
881
- self . onchain_detection . keys . write ( writer) ?;
882
- match self . onchain_detection . funding_info {
874
+ self . keys . write ( writer) ?;
875
+ match self . funding_info {
883
876
Some ( ( ref outpoint, ref script) ) => {
884
877
writer. write_all ( & outpoint. txid [ ..] ) ?;
885
878
writer. write_all ( & byte_utils:: be16_to_array ( outpoint. index ) ) ?;
@@ -889,8 +882,8 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
889
882
debug_assert ! ( false , "Try to serialize a useless Local monitor !" ) ;
890
883
} ,
891
884
}
892
- self . onchain_detection . current_remote_commitment_txid . write ( writer) ?;
893
- self . onchain_detection . prev_remote_commitment_txid . write ( writer) ?;
885
+ self . current_remote_commitment_txid . write ( writer) ?;
886
+ self . prev_remote_commitment_txid . write ( writer) ?;
894
887
895
888
writer. write_all ( & self . their_htlc_base_key . as_ref ( ) . unwrap ( ) . serialize ( ) ) ?;
896
889
writer. write_all ( & self . their_delayed_payment_base_key . as_ref ( ) . unwrap ( ) . serialize ( ) ) ?;
@@ -1096,13 +1089,6 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1096
1089
let our_channel_close_key_hash = Hash160 :: hash ( & shutdown_pubkey. serialize ( ) ) ;
1097
1090
let shutdown_script = Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 ) . push_slice ( & our_channel_close_key_hash[ ..] ) . into_script ( ) ;
1098
1091
1099
- let onchain_detection = OnchainDetection {
1100
- keys : keys. clone ( ) ,
1101
- funding_info : Some ( funding_info. clone ( ) ) ,
1102
- current_remote_commitment_txid : None ,
1103
- prev_remote_commitment_txid : None ,
1104
- } ;
1105
-
1106
1092
ChannelMonitor {
1107
1093
latest_update_id : 0 ,
1108
1094
commitment_transaction_number_obscure_factor,
@@ -1112,7 +1098,11 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1112
1098
broadcasted_remote_payment_script : None ,
1113
1099
shutdown_script,
1114
1100
1115
- onchain_detection : onchain_detection,
1101
+ keys : keys. clone ( ) ,
1102
+ funding_info : Some ( funding_info) ,
1103
+ current_remote_commitment_txid : None ,
1104
+ prev_remote_commitment_txid : None ,
1105
+
1116
1106
their_htlc_base_key : Some ( their_htlc_base_key. clone ( ) ) ,
1117
1107
their_delayed_payment_base_key : Some ( their_delayed_payment_base_key. clone ( ) ) ,
1118
1108
funding_redeemscript : Some ( funding_redeemscript. clone ( ) ) ,
@@ -1159,7 +1149,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1159
1149
1160
1150
// Prune HTLCs from the previous remote commitment tx so we don't generate failure/fulfill
1161
1151
// events for now-revoked/fulfilled HTLCs.
1162
- if let Some ( txid) = self . onchain_detection . prev_remote_commitment_txid . take ( ) {
1152
+ if let Some ( txid) = self . prev_remote_commitment_txid . take ( ) {
1163
1153
for & mut ( _, ref mut source) in self . remote_claimable_outpoints . get_mut ( & txid) . unwrap ( ) {
1164
1154
* source = None ;
1165
1155
}
@@ -1216,8 +1206,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1216
1206
let new_txid = unsigned_commitment_tx. txid ( ) ;
1217
1207
log_trace ! ( self , "Tracking new remote commitment transaction with txid {} at commitment number {} with {} HTLC outputs" , new_txid, commitment_number, htlc_outputs. len( ) ) ;
1218
1208
log_trace ! ( self , "New potential remote commitment transaction: {}" , encode:: serialize_hex( unsigned_commitment_tx) ) ;
1219
- self . onchain_detection . prev_remote_commitment_txid = self . onchain_detection . current_remote_commitment_txid . take ( ) ;
1220
- self . onchain_detection . current_remote_commitment_txid = Some ( new_txid) ;
1209
+ self . prev_remote_commitment_txid = self . current_remote_commitment_txid . take ( ) ;
1210
+ self . current_remote_commitment_txid = Some ( new_txid) ;
1221
1211
self . remote_claimable_outpoints . insert ( new_txid, htlc_outputs) ;
1222
1212
self . current_remote_commitment_number = commitment_number;
1223
1213
//TODO: Merge this into the other per-remote-transaction output storage stuff
@@ -1242,11 +1232,11 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1242
1232
}
1243
1233
1244
1234
pub ( super ) fn provide_rescue_remote_commitment_tx_info ( & mut self , their_revocation_point : PublicKey ) {
1245
- if let Ok ( payment_key) = chan_utils:: derive_public_key ( & self . secp_ctx , & their_revocation_point, & self . onchain_detection . keys . pubkeys ( ) . payment_basepoint ) {
1235
+ if let Ok ( payment_key) = chan_utils:: derive_public_key ( & self . secp_ctx , & their_revocation_point, & self . keys . pubkeys ( ) . payment_basepoint ) {
1246
1236
let to_remote_script = Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 )
1247
1237
. push_slice ( & Hash160 :: hash ( & payment_key. serialize ( ) ) [ ..] )
1248
1238
. into_script ( ) ;
1249
- if let Ok ( to_remote_key) = chan_utils:: derive_private_key ( & self . secp_ctx , & their_revocation_point, & self . onchain_detection . keys . payment_base_key ( ) ) {
1239
+ if let Ok ( to_remote_key) = chan_utils:: derive_private_key ( & self . secp_ctx , & their_revocation_point, & self . keys . payment_base_key ( ) ) {
1250
1240
self . broadcasted_remote_payment_script = Some ( ( to_remote_script, to_remote_key) ) ;
1251
1241
}
1252
1242
}
@@ -1377,7 +1367,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1377
1367
1378
1368
/// Gets the funding transaction outpoint of the channel this ChannelMonitor is monitoring for.
1379
1369
pub fn get_funding_txo ( & self ) -> Option < OutPoint > {
1380
- if let Some ( ( outp, _) ) = self . onchain_detection . funding_info {
1370
+ if let Some ( ( outp, _) ) = self . funding_info {
1381
1371
return Some ( outp)
1382
1372
}
1383
1373
None
@@ -1469,10 +1459,10 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1469
1459
let secret = self . get_secret ( commitment_number) . unwrap ( ) ;
1470
1460
let per_commitment_key = ignore_error ! ( SecretKey :: from_slice( & secret) ) ;
1471
1461
let per_commitment_point = PublicKey :: from_secret_key ( & self . secp_ctx , & per_commitment_key) ;
1472
- let revocation_pubkey = ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, & per_commitment_point, & self . onchain_detection . keys. pubkeys( ) . revocation_basepoint) ) ;
1473
- let revocation_key = ignore_error ! ( chan_utils:: derive_private_revocation_key( & self . secp_ctx, & per_commitment_key, & self . onchain_detection . keys. revocation_base_key( ) ) ) ;
1474
- let b_htlc_key = ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, & per_commitment_point, & self . onchain_detection . keys. pubkeys( ) . htlc_basepoint) ) ;
1475
- let local_payment_key = ignore_error ! ( chan_utils:: derive_private_key( & self . secp_ctx, & per_commitment_point, & self . onchain_detection . keys. payment_base_key( ) ) ) ;
1462
+ let revocation_pubkey = ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, & per_commitment_point, & self . keys. pubkeys( ) . revocation_basepoint) ) ;
1463
+ let revocation_key = ignore_error ! ( chan_utils:: derive_private_revocation_key( & self . secp_ctx, & per_commitment_key, & self . keys. revocation_base_key( ) ) ) ;
1464
+ let b_htlc_key = ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, & per_commitment_point, & self . keys. pubkeys( ) . htlc_basepoint) ) ;
1465
+ let local_payment_key = ignore_error ! ( chan_utils:: derive_private_key( & self . secp_ctx, & per_commitment_point, & self . keys. payment_base_key( ) ) ) ;
1476
1466
let delayed_key = ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, & PublicKey :: from_secret_key( & self . secp_ctx, & per_commitment_key) , & self . their_delayed_payment_base_key. unwrap( ) ) ) ;
1477
1467
let a_htlc_key = match self . their_htlc_base_key {
1478
1468
None => return ( claimable_outpoints, ( commitment_txid, watch_outputs) ) ,
@@ -1548,10 +1538,10 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1548
1538
}
1549
1539
}
1550
1540
}
1551
- if let Some ( ref txid) = self . onchain_detection . current_remote_commitment_txid {
1541
+ if let Some ( ref txid) = self . current_remote_commitment_txid {
1552
1542
check_htlc_fails ! ( txid, "current" ) ;
1553
1543
}
1554
- if let Some ( ref txid) = self . onchain_detection . prev_remote_commitment_txid {
1544
+ if let Some ( ref txid) = self . prev_remote_commitment_txid {
1555
1545
check_htlc_fails ! ( txid, "remote" ) ;
1556
1546
}
1557
1547
// No need to check local commitment txn, symmetric HTLCSource must be present as per-htlc data on remote commitment tx
@@ -1611,10 +1601,10 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1611
1601
}
1612
1602
}
1613
1603
}
1614
- if let Some ( ref txid) = self . onchain_detection . current_remote_commitment_txid {
1604
+ if let Some ( ref txid) = self . current_remote_commitment_txid {
1615
1605
check_htlc_fails ! ( txid, "current" , ' current_loop) ;
1616
1606
}
1617
- if let Some ( ref txid) = self . onchain_detection . prev_remote_commitment_txid {
1607
+ if let Some ( ref txid) = self . prev_remote_commitment_txid {
1618
1608
check_htlc_fails ! ( txid, "previous" , ' prev_loop) ;
1619
1609
}
1620
1610
@@ -1625,14 +1615,14 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1625
1615
if revocation_points. 0 == commitment_number + 1 { Some ( point) } else { None }
1626
1616
} else { None } ;
1627
1617
if let Some ( revocation_point) = revocation_point_option {
1628
- let revocation_pubkey = ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, revocation_point, & self . onchain_detection . keys. pubkeys( ) . revocation_basepoint) ) ;
1629
- let b_htlc_key = ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, revocation_point, & self . onchain_detection . keys. pubkeys( ) . htlc_basepoint) ) ;
1630
- let htlc_privkey = ignore_error ! ( chan_utils:: derive_private_key( & self . secp_ctx, revocation_point, & self . onchain_detection . keys. htlc_base_key( ) ) ) ;
1618
+ let revocation_pubkey = ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, revocation_point, & self . keys. pubkeys( ) . revocation_basepoint) ) ;
1619
+ let b_htlc_key = ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, revocation_point, & self . keys. pubkeys( ) . htlc_basepoint) ) ;
1620
+ let htlc_privkey = ignore_error ! ( chan_utils:: derive_private_key( & self . secp_ctx, revocation_point, & self . keys. htlc_base_key( ) ) ) ;
1631
1621
let a_htlc_key = match self . their_htlc_base_key {
1632
1622
None => return ( claimable_outpoints, ( commitment_txid, watch_outputs) ) ,
1633
1623
Some ( their_htlc_base_key) => ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, revocation_point, & their_htlc_base_key) ) ,
1634
1624
} ;
1635
- let local_payment_key = ignore_error ! ( chan_utils:: derive_private_key( & self . secp_ctx, revocation_point, & self . onchain_detection . keys. payment_base_key( ) ) ) ;
1625
+ let local_payment_key = ignore_error ! ( chan_utils:: derive_private_key( & self . secp_ctx, revocation_point, & self . keys. payment_base_key( ) ) ) ;
1636
1626
1637
1627
self . broadcasted_remote_payment_script = {
1638
1628
// Note that the Network here is ignored as we immediately drop the address for the
@@ -1683,8 +1673,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1683
1673
let secret = if let Some ( secret) = self . get_secret ( commitment_number) { secret } else { return ( Vec :: new ( ) , None ) ; } ;
1684
1674
let per_commitment_key = ignore_error ! ( SecretKey :: from_slice( & secret) ) ;
1685
1675
let per_commitment_point = PublicKey :: from_secret_key ( & self . secp_ctx , & per_commitment_key) ;
1686
- let revocation_pubkey = ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, & per_commitment_point, & self . onchain_detection . keys. pubkeys( ) . revocation_basepoint) ) ;
1687
- let revocation_key = ignore_error ! ( chan_utils:: derive_private_revocation_key( & self . secp_ctx, & per_commitment_key, & self . onchain_detection . keys. revocation_base_key( ) ) ) ;
1676
+ let revocation_pubkey = ignore_error ! ( chan_utils:: derive_public_revocation_key( & self . secp_ctx, & per_commitment_point, & self . keys. pubkeys( ) . revocation_basepoint) ) ;
1677
+ let revocation_key = ignore_error ! ( chan_utils:: derive_private_revocation_key( & self . secp_ctx, & per_commitment_key, & self . keys. revocation_base_key( ) ) ) ;
1688
1678
let delayed_key = match self . their_delayed_payment_base_key {
1689
1679
None => return ( Vec :: new ( ) , None ) ,
1690
1680
Some ( their_delayed_payment_base_key) => ignore_error ! ( chan_utils:: derive_public_key( & self . secp_ctx, & per_commitment_point, & their_delayed_payment_base_key) ) ,
@@ -1702,7 +1692,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1702
1692
let mut watch_outputs = Vec :: with_capacity ( local_tx. htlc_outputs . len ( ) ) ;
1703
1693
1704
1694
let redeemscript = chan_utils:: get_revokeable_redeemscript ( & local_tx. revocation_key , self . their_to_self_delay . unwrap ( ) , & local_tx. delayed_payment_key ) ;
1705
- let broadcasted_local_revokable_script = if let Ok ( local_delayedkey) = chan_utils:: derive_private_key ( & self . secp_ctx , & local_tx. per_commitment_point , self . onchain_detection . keys . delayed_payment_base_key ( ) ) {
1695
+ let broadcasted_local_revokable_script = if let Ok ( local_delayedkey) = chan_utils:: derive_private_key ( & self . secp_ctx , & local_tx. per_commitment_point , self . keys . delayed_payment_base_key ( ) ) {
1706
1696
Some ( ( redeemscript. to_v0_p2wsh ( ) , local_delayedkey, redeemscript) )
1707
1697
} else { None } ;
1708
1698
@@ -1883,7 +1873,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1883
1873
// which is an easy way to filter out any potential non-matching txn for lazy
1884
1874
// filters.
1885
1875
let prevout = & tx. input [ 0 ] . previous_output ;
1886
- let funding_txo = self . onchain_detection . funding_info . clone ( ) ;
1876
+ let funding_txo = self . funding_info . clone ( ) ;
1887
1877
if funding_txo. is_none ( ) || ( prevout. txid == funding_txo. as_ref ( ) . unwrap ( ) . 0 . txid && prevout. vout == funding_txo. as_ref ( ) . unwrap ( ) . 0 . index as u32 ) {
1888
1878
if ( tx. input [ 0 ] . sequence >> 8 * 3 ) as u8 == 0x80 && ( tx. lock_time >> 8 * 3 ) as u8 == 0x20 {
1889
1879
let ( mut new_outpoints, new_outputs) = self . check_spend_remote_transaction ( & tx, height) ;
@@ -1920,7 +1910,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1920
1910
self . would_broadcast_at_height ( height)
1921
1911
} else { false } ;
1922
1912
if should_broadcast {
1923
- claimable_outpoints. push ( ClaimRequest { absolute_timelock : height, aggregable : false , outpoint : BitcoinOutPoint { txid : self . onchain_detection . funding_info . as_ref ( ) . unwrap ( ) . 0 . txid . clone ( ) , vout : self . onchain_detection . funding_info . as_ref ( ) . unwrap ( ) . 0 . index as u32 } , witness_data : InputMaterial :: Funding { channel_value : self . channel_value_satoshis . unwrap ( ) } } ) ;
1913
+ claimable_outpoints. push ( ClaimRequest { absolute_timelock : height, aggregable : false , outpoint : BitcoinOutPoint { txid : self . funding_info . as_ref ( ) . unwrap ( ) . 0 . txid . clone ( ) , vout : self . funding_info . as_ref ( ) . unwrap ( ) . 0 . index as u32 } , witness_data : InputMaterial :: Funding { channel_value : self . channel_value_satoshis . unwrap ( ) } } ) ;
1924
1914
}
1925
1915
if let Some ( ref cur_local_tx) = self . current_local_signed_commitment_tx {
1926
1916
if should_broadcast {
@@ -2030,12 +2020,12 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
2030
2020
scan_commitment ! ( cur_local_tx. htlc_outputs. iter( ) . map( |& ( ref a, _, _) | a) , true ) ;
2031
2021
}
2032
2022
2033
- if let Some ( ref txid) = self . onchain_detection . current_remote_commitment_txid {
2023
+ if let Some ( ref txid) = self . current_remote_commitment_txid {
2034
2024
if let Some ( ref htlc_outputs) = self . remote_claimable_outpoints . get ( txid) {
2035
2025
scan_commitment ! ( htlc_outputs. iter( ) . map( |& ( ref a, _) | a) , false ) ;
2036
2026
}
2037
2027
}
2038
- if let Some ( ref txid) = self . onchain_detection . prev_remote_commitment_txid {
2028
+ if let Some ( ref txid) = self . prev_remote_commitment_txid {
2039
2029
if let Some ( ref htlc_outputs) = self . remote_claimable_outpoints . get ( txid) {
2040
2030
scan_commitment ! ( htlc_outputs. iter( ) . map( |& ( ref a, _) | a) , false ) ;
2041
2031
}
@@ -2105,9 +2095,9 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
2105
2095
// resolve the source HTLC with the original sender.
2106
2096
payment_data = Some ( ( ( * source) . clone( ) , htlc_output. payment_hash) ) ;
2107
2097
} else if !$local_tx {
2108
- check_htlc_valid_remote!( self . onchain_detection . current_remote_commitment_txid, htlc_output) ;
2098
+ check_htlc_valid_remote!( self . current_remote_commitment_txid, htlc_output) ;
2109
2099
if payment_data. is_none( ) {
2110
- check_htlc_valid_remote!( self . onchain_detection . prev_remote_commitment_txid, htlc_output) ;
2100
+ check_htlc_valid_remote!( self . prev_remote_commitment_txid, htlc_output) ;
2111
2101
}
2112
2102
}
2113
2103
if payment_data. is_none( ) {
@@ -2278,24 +2268,16 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (Sha256dH
2278
2268
} ;
2279
2269
let shutdown_script = Readable :: read ( reader) ?;
2280
2270
2281
- let onchain_detection = {
2282
- let keys = Readable :: read ( reader) ?;
2283
- // Technically this can fail and serialize fail a round-trip, but only for serialization of
2284
- // barely-init'd ChannelMonitors that we can't do anything with.
2285
- let outpoint = OutPoint {
2286
- txid : Readable :: read ( reader) ?,
2287
- index : Readable :: read ( reader) ?,
2288
- } ;
2289
- let funding_info = Some ( ( outpoint, Readable :: read ( reader) ?) ) ;
2290
- let current_remote_commitment_txid = Readable :: read ( reader) ?;
2291
- let prev_remote_commitment_txid = Readable :: read ( reader) ?;
2292
- OnchainDetection {
2293
- keys,
2294
- funding_info,
2295
- current_remote_commitment_txid,
2296
- prev_remote_commitment_txid,
2297
- }
2271
+ let keys = Readable :: read ( reader) ?;
2272
+ // Technically this can fail and serialize fail a round-trip, but only for serialization of
2273
+ // barely-init'd ChannelMonitors that we can't do anything with.
2274
+ let outpoint = OutPoint {
2275
+ txid : Readable :: read ( reader) ?,
2276
+ index : Readable :: read ( reader) ?,
2298
2277
} ;
2278
+ let funding_info = Some ( ( outpoint, Readable :: read ( reader) ?) ) ;
2279
+ let current_remote_commitment_txid = Readable :: read ( reader) ?;
2280
+ let prev_remote_commitment_txid = Readable :: read ( reader) ?;
2299
2281
2300
2282
let their_htlc_base_key = Some ( Readable :: read ( reader) ?) ;
2301
2283
let their_delayed_payment_base_key = Some ( Readable :: read ( reader) ?) ;
@@ -2508,7 +2490,11 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (Sha256dH
2508
2490
broadcasted_remote_payment_script,
2509
2491
shutdown_script,
2510
2492
2511
- onchain_detection,
2493
+ keys,
2494
+ funding_info,
2495
+ current_remote_commitment_txid,
2496
+ prev_remote_commitment_txid,
2497
+
2512
2498
their_htlc_base_key,
2513
2499
their_delayed_payment_base_key,
2514
2500
funding_redeemscript,
0 commit comments