@@ -722,6 +722,9 @@ pub(crate) struct ChannelMonitorImpl<Signer: Sign> {
722
722
// the full block_connected).
723
723
best_block : BestBlock ,
724
724
725
+ /// The node_id of our counterparty
726
+ counterparty_node_id : Option < PublicKey > ,
727
+
725
728
secp_ctx : Secp256k1 < secp256k1:: All > , //TODO: dedup this a bit...
726
729
}
727
730
@@ -954,6 +957,7 @@ impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
954
957
( 3 , self . htlcs_resolved_on_chain, vec_type) ,
955
958
( 5 , self . pending_monitor_events, vec_type) ,
956
959
( 7 , self . funding_spend_seen, required) ,
960
+ ( 9 , self . counterparty_node_id, option) ,
957
961
} ) ;
958
962
959
963
Ok ( ( ) )
@@ -967,7 +971,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
967
971
funding_redeemscript : Script , channel_value_satoshis : u64 ,
968
972
commitment_transaction_number_obscure_factor : u64 ,
969
973
initial_holder_commitment_tx : HolderCommitmentTransaction ,
970
- best_block : BestBlock ) -> ChannelMonitor < Signer > {
974
+ best_block : BestBlock , counterparty_node_id : PublicKey ) -> ChannelMonitor < Signer > {
971
975
972
976
assert ! ( commitment_transaction_number_obscure_factor <= ( 1 << 48 ) ) ;
973
977
let payment_key_hash = WPubkeyHash :: hash ( & keys. pubkeys ( ) . payment_point . serialize ( ) ) ;
@@ -1057,6 +1061,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
1057
1061
htlcs_resolved_on_chain : Vec :: new ( ) ,
1058
1062
1059
1063
best_block,
1064
+ counterparty_node_id : Some ( counterparty_node_id) ,
1060
1065
1061
1066
secp_ctx,
1062
1067
} ) ,
@@ -3336,11 +3341,13 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
3336
3341
let mut funding_spend_confirmed = None ;
3337
3342
let mut htlcs_resolved_on_chain = Some ( Vec :: new ( ) ) ;
3338
3343
let mut funding_spend_seen = Some ( false ) ;
3344
+ let mut counterparty_node_id = None ;
3339
3345
read_tlv_fields ! ( reader, {
3340
3346
( 1 , funding_spend_confirmed, option) ,
3341
3347
( 3 , htlcs_resolved_on_chain, vec_type) ,
3342
3348
( 5 , pending_monitor_events, vec_type) ,
3343
3349
( 7 , funding_spend_seen, option) ,
3350
+ ( 9 , counterparty_node_id, option) ,
3344
3351
} ) ;
3345
3352
3346
3353
let mut secp_ctx = Secp256k1 :: new ( ) ;
@@ -3395,6 +3402,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
3395
3402
htlcs_resolved_on_chain : htlcs_resolved_on_chain. unwrap ( ) ,
3396
3403
3397
3404
best_block,
3405
+ counterparty_node_id,
3398
3406
3399
3407
secp_ctx,
3400
3408
} ) ,
@@ -3631,7 +3639,7 @@ mod tests {
3631
3639
( OutPoint { txid : Txid :: from_slice ( & [ 43 ; 32 ] ) . unwrap ( ) , index : 0 } , Script :: new ( ) ) ,
3632
3640
& channel_parameters,
3633
3641
Script :: new ( ) , 46 , 0 ,
3634
- HolderCommitmentTransaction :: dummy ( ) , best_block) ;
3642
+ HolderCommitmentTransaction :: dummy ( ) , best_block, dummy_key ) ;
3635
3643
3636
3644
monitor. provide_latest_holder_commitment_tx ( HolderCommitmentTransaction :: dummy ( ) , preimages_to_holder_htlcs ! ( preimages[ 0 ..10 ] ) ) . unwrap ( ) ;
3637
3645
let dummy_txid = dummy_tx. txid ( ) ;
0 commit comments