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.
This commit is contained in:
Antoine Riard 2020-03-23 01:36:37 -04:00
parent 080afeb6ea
commit 6b8a516647
2 changed files with 7 additions and 2 deletions

View file

@ -1145,7 +1145,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
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(),

View file

@ -157,6 +157,7 @@ pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
prev_local_commitment: Option<LocalCommitmentTransaction>,
current_htlc_cache: Option<HTLCTxCache>,
prev_htlc_cache: Option<HTLCTxCache>,
local_csv: u16,
key_storage: ChanSigner,
@ -230,6 +231,7 @@ impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
} else {
writer.write_all(&[0; 1])?;
}
self.local_csv.write(writer)?;
self.key_storage.write(writer)?;
@ -315,6 +317,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
}
_ => return Err(DecodeError::InvalidValue),
};
let local_csv = Readable::read(reader)?;
let key_storage = Readable::read(reader)?;
@ -368,6 +371,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> 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<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
}
impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, logger: Arc<Logger>) -> Self {
pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, local_csv: u16, logger: Arc<Logger>) -> Self {
let key_storage = keys;
@ -390,6 +394,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
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(),