From 6b8a5166476228f93a06fe55db40fd9715b118ad Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Mon, 23 Mar 2020 01:36:37 -0400 Subject: [PATCH] Cache csv_local inside OnchainTxHandler csv_local is csv_delay encumbering local revokable_redeemscript for to_local an htlc output on local commitment/HTLC transactions. --- lightning/src/ln/channelmonitor.rs | 2 +- lightning/src/ln/onchaintx.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 4a89f5002..0f6cc826e 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -1145,7 +1145,7 @@ impl ChannelMonitor { onchain_events_waiting_threshold_conf: HashMap::new(), outputs_to_watch: HashMap::new(), - onchain_tx_handler: OnchainTxHandler::new(destination_script.clone(), keys, funding_redeemscript, logger.clone()), + onchain_tx_handler: OnchainTxHandler::new(destination_script.clone(), keys, funding_redeemscript, their_to_self_delay, logger.clone()), last_block_hash: Default::default(), secp_ctx: Secp256k1::new(), diff --git a/lightning/src/ln/onchaintx.rs b/lightning/src/ln/onchaintx.rs index 406d9f38b..fce935549 100644 --- a/lightning/src/ln/onchaintx.rs +++ b/lightning/src/ln/onchaintx.rs @@ -157,6 +157,7 @@ pub struct OnchainTxHandler { prev_local_commitment: Option, current_htlc_cache: Option, prev_htlc_cache: Option, + local_csv: u16, key_storage: ChanSigner, @@ -230,6 +231,7 @@ impl OnchainTxHandler { } else { writer.write_all(&[0; 1])?; } + self.local_csv.write(writer)?; self.key_storage.write(writer)?; @@ -315,6 +317,7 @@ impl ReadableArgs> for OnchainTx } _ => return Err(DecodeError::InvalidValue), }; + let local_csv = Readable::read(reader)?; let key_storage = Readable::read(reader)?; @@ -368,6 +371,7 @@ impl ReadableArgs> for OnchainTx prev_local_commitment, current_htlc_cache, prev_htlc_cache, + local_csv, key_storage, claimable_outpoints, pending_claim_requests, @@ -379,7 +383,7 @@ impl ReadableArgs> for OnchainTx } impl OnchainTxHandler { - pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, logger: Arc) -> Self { + pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, local_csv: u16, logger: Arc) -> Self { let key_storage = keys; @@ -390,6 +394,7 @@ impl OnchainTxHandler { prev_local_commitment: None, current_htlc_cache: None, prev_htlc_cache: None, + local_csv, key_storage, pending_claim_requests: HashMap::new(), claimable_outpoints: HashMap::new(), -- 2.39.5