mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +01:00
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:
parent
080afeb6ea
commit
6b8a516647
2 changed files with 7 additions and 2 deletions
|
@ -1145,7 +1145,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
|
||||||
onchain_events_waiting_threshold_conf: HashMap::new(),
|
onchain_events_waiting_threshold_conf: HashMap::new(),
|
||||||
outputs_to_watch: 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(),
|
last_block_hash: Default::default(),
|
||||||
secp_ctx: Secp256k1::new(),
|
secp_ctx: Secp256k1::new(),
|
||||||
|
|
|
@ -157,6 +157,7 @@ pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
|
||||||
prev_local_commitment: Option<LocalCommitmentTransaction>,
|
prev_local_commitment: Option<LocalCommitmentTransaction>,
|
||||||
current_htlc_cache: Option<HTLCTxCache>,
|
current_htlc_cache: Option<HTLCTxCache>,
|
||||||
prev_htlc_cache: Option<HTLCTxCache>,
|
prev_htlc_cache: Option<HTLCTxCache>,
|
||||||
|
local_csv: u16,
|
||||||
|
|
||||||
key_storage: ChanSigner,
|
key_storage: ChanSigner,
|
||||||
|
|
||||||
|
@ -230,6 +231,7 @@ impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
|
||||||
} else {
|
} else {
|
||||||
writer.write_all(&[0; 1])?;
|
writer.write_all(&[0; 1])?;
|
||||||
}
|
}
|
||||||
|
self.local_csv.write(writer)?;
|
||||||
|
|
||||||
self.key_storage.write(writer)?;
|
self.key_storage.write(writer)?;
|
||||||
|
|
||||||
|
@ -315,6 +317,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
|
||||||
}
|
}
|
||||||
_ => return Err(DecodeError::InvalidValue),
|
_ => return Err(DecodeError::InvalidValue),
|
||||||
};
|
};
|
||||||
|
let local_csv = Readable::read(reader)?;
|
||||||
|
|
||||||
let key_storage = 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,
|
prev_local_commitment,
|
||||||
current_htlc_cache,
|
current_htlc_cache,
|
||||||
prev_htlc_cache,
|
prev_htlc_cache,
|
||||||
|
local_csv,
|
||||||
key_storage,
|
key_storage,
|
||||||
claimable_outpoints,
|
claimable_outpoints,
|
||||||
pending_claim_requests,
|
pending_claim_requests,
|
||||||
|
@ -379,7 +383,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
|
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;
|
let key_storage = keys;
|
||||||
|
|
||||||
|
@ -390,6 +394,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
|
||||||
prev_local_commitment: None,
|
prev_local_commitment: None,
|
||||||
current_htlc_cache: None,
|
current_htlc_cache: None,
|
||||||
prev_htlc_cache: None,
|
prev_htlc_cache: None,
|
||||||
|
local_csv,
|
||||||
key_storage,
|
key_storage,
|
||||||
pending_claim_requests: HashMap::new(),
|
pending_claim_requests: HashMap::new(),
|
||||||
claimable_outpoints: HashMap::new(),
|
claimable_outpoints: HashMap::new(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue