X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fchain%2Fchannelmonitor.rs;h=6492ba176e8f43877615d99fd6f202a02a772e51;hb=2d493364db426bb19d1f3c6ff44cf7a4f569dde3;hp=48f821d5f0cb712292fee1afda7e94e627c85a36;hpb=6c480ae887b751e868423d606d706e352d9615f0;p=rust-lightning diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 48f821d5..6492ba17 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -722,6 +722,9 @@ pub(crate) struct ChannelMonitorImpl { // the full block_connected). best_block: BestBlock, + /// The node_id of our counterparty + counterparty_node_id: Option, + secp_ctx: Secp256k1, //TODO: dedup this a bit... } @@ -954,6 +957,7 @@ impl Writeable for ChannelMonitorImpl { (3, self.htlcs_resolved_on_chain, vec_type), (5, self.pending_monitor_events, vec_type), (7, self.funding_spend_seen, required), + (9, self.counterparty_node_id, option), }); Ok(()) @@ -967,7 +971,7 @@ impl ChannelMonitor { funding_redeemscript: Script, channel_value_satoshis: u64, commitment_transaction_number_obscure_factor: u64, initial_holder_commitment_tx: HolderCommitmentTransaction, - best_block: BestBlock) -> ChannelMonitor { + best_block: BestBlock, counterparty_node_id: PublicKey) -> ChannelMonitor { assert!(commitment_transaction_number_obscure_factor <= (1 << 48)); let payment_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_point.serialize()); @@ -1057,6 +1061,7 @@ impl ChannelMonitor { htlcs_resolved_on_chain: Vec::new(), best_block, + counterparty_node_id: Some(counterparty_node_id), secp_ctx, }), @@ -3336,11 +3341,13 @@ impl<'a, Signer: Sign, K: KeysInterface> ReadableArgs<&'a K> let mut funding_spend_confirmed = None; let mut htlcs_resolved_on_chain = Some(Vec::new()); let mut funding_spend_seen = Some(false); + let mut counterparty_node_id = None; read_tlv_fields!(reader, { (1, funding_spend_confirmed, option), (3, htlcs_resolved_on_chain, vec_type), (5, pending_monitor_events, vec_type), (7, funding_spend_seen, option), + (9, counterparty_node_id, option), }); let mut secp_ctx = Secp256k1::new(); @@ -3395,6 +3402,7 @@ impl<'a, Signer: Sign, K: KeysInterface> ReadableArgs<&'a K> htlcs_resolved_on_chain: htlcs_resolved_on_chain.unwrap(), best_block, + counterparty_node_id, secp_ctx, }), @@ -3631,7 +3639,7 @@ mod tests { (OutPoint { txid: Txid::from_slice(&[43; 32]).unwrap(), index: 0 }, Script::new()), &channel_parameters, Script::new(), 46, 0, - HolderCommitmentTransaction::dummy(), best_block); + HolderCommitmentTransaction::dummy(), best_block, dummy_key); monitor.provide_latest_holder_commitment_tx(HolderCommitmentTransaction::dummy(), preimages_to_holder_htlcs!(preimages[0..10])).unwrap(); let dummy_txid = dummy_tx.txid();