@@ -695,6 +695,8 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
695
695
// the full block_connected).
696
696
last_block_hash : BlockHash ,
697
697
secp_ctx : Secp256k1 < secp256k1:: All > , //TODO: dedup this a bit...
698
+
699
+ counterparty_node_id : PublicKey
698
700
}
699
701
700
702
#[ cfg( any( test, feature = "fuzztarget" ) ) ]
@@ -927,6 +929,7 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
927
929
928
930
self . lockdown_from_offchain . write ( writer) ?;
929
931
self . holder_tx_signed . write ( writer) ?;
932
+ self . counterparty_node_id . write ( writer) ?;
930
933
931
934
Ok ( ( ) )
932
935
}
@@ -938,7 +941,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
938
941
counterparty_htlc_base_key : & PublicKey , counterparty_delayed_payment_base_key : & PublicKey ,
939
942
on_holder_tx_csv : u16 , funding_redeemscript : Script , channel_value_satoshis : u64 ,
940
943
commitment_transaction_number_obscure_factor : u64 ,
941
- initial_holder_commitment_tx : HolderCommitmentTransaction ) -> ChannelMonitor < ChanSigner > {
944
+ initial_holder_commitment_tx : HolderCommitmentTransaction ,
945
+ counterparty_node_id : PublicKey ) -> ChannelMonitor < ChanSigner > {
942
946
943
947
assert ! ( commitment_transaction_number_obscure_factor <= ( 1 << 48 ) ) ;
944
948
let our_channel_close_key_hash = WPubkeyHash :: hash ( & shutdown_pubkey. serialize ( ) ) ;
@@ -1010,6 +1014,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1010
1014
lockdown_from_offchain : false ,
1011
1015
holder_tx_signed : false ,
1012
1016
1017
+ counterparty_node_id,
1018
+
1013
1019
last_block_hash : Default :: default ( ) ,
1014
1020
secp_ctx : Secp256k1 :: new ( ) ,
1015
1021
}
@@ -1755,7 +1761,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1755
1761
source : htlc_update. 0 ,
1756
1762
monitor_info : MonitorUpdateInfo {
1757
1763
funding_outpoint : self . funding_info . 0 ,
1758
- latest_monitor_update_id
1764
+ latest_monitor_update_id,
1765
+ counterparty_node_id : self . counterparty_node_id
1759
1766
}
1760
1767
} ) ) ;
1761
1768
} ,
@@ -2029,7 +2036,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
2029
2036
payment_hash,
2030
2037
monitor_info : MonitorUpdateInfo {
2031
2038
funding_outpoint : self . funding_info . 0 ,
2032
- latest_monitor_update_id
2039
+ latest_monitor_update_id,
2040
+ counterparty_node_id : self . counterparty_node_id
2033
2041
}
2034
2042
} ) ) ;
2035
2043
}
@@ -2046,7 +2054,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
2046
2054
payment_hash,
2047
2055
monitor_info : MonitorUpdateInfo {
2048
2056
funding_outpoint : self . funding_info . 0 ,
2049
- latest_monitor_update_id
2057
+ latest_monitor_update_id,
2058
+ counterparty_node_id : self . counterparty_node_id
2050
2059
}
2051
2060
} ) ) ;
2052
2061
}
@@ -2379,6 +2388,7 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for (BlockHash, ChannelMonitor
2379
2388
2380
2389
let lockdown_from_offchain = Readable :: read ( reader) ?;
2381
2390
let holder_tx_signed = Readable :: read ( reader) ?;
2391
+ let counterparty_node_id = Readable :: read ( reader) ?;
2382
2392
2383
2393
Ok ( ( last_block_hash. clone ( ) , ChannelMonitor {
2384
2394
latest_update_id,
@@ -2423,6 +2433,8 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for (BlockHash, ChannelMonitor
2423
2433
lockdown_from_offchain,
2424
2434
holder_tx_signed,
2425
2435
2436
+ counterparty_node_id,
2437
+
2426
2438
last_block_hash,
2427
2439
secp_ctx : Secp256k1 :: new ( ) ,
2428
2440
} ) )
@@ -2459,6 +2471,7 @@ mod tests {
2459
2471
let logger = Arc :: new ( TestLogger :: new ( ) ) ;
2460
2472
2461
2473
let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
2474
+ let dummy_counterparty_nodeid = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) ) ;
2462
2475
let dummy_tx = Transaction { version : 0 , lock_time : 0 , input : Vec :: new ( ) , output : Vec :: new ( ) } ;
2463
2476
2464
2477
let mut preimages = Vec :: new ( ) ;
@@ -2524,7 +2537,7 @@ mod tests {
2524
2537
( OutPoint { txid : Txid :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) , index : 0 } , Script :: new ( ) ) ,
2525
2538
& PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 44 ; 32 ] ) . unwrap ( ) ) ,
2526
2539
& PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 45 ; 32 ] ) . unwrap ( ) ) ,
2527
- 10 , Script :: new ( ) , 46 , 0 , HolderCommitmentTransaction :: dummy ( ) ) ;
2540
+ 10 , Script :: new ( ) , 46 , 0 , HolderCommitmentTransaction :: dummy ( ) , dummy_counterparty_nodeid ) ;
2528
2541
2529
2542
monitor. provide_latest_holder_commitment_tx_info ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..10 ] ) ) . unwrap ( ) ;
2530
2543
monitor. provide_latest_counterparty_commitment_tx_info ( & dummy_tx, preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
0 commit comments