Skip to content

Commit eb81834

Browse files
author
Antoine Riard
committed
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.
1 parent 2760586 commit eb81834

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
11451145
onchain_events_waiting_threshold_conf: HashMap::new(),
11461146
outputs_to_watch: HashMap::new(),
11471147

1148-
onchain_tx_handler: OnchainTxHandler::new(destination_script.clone(), keys, funding_redeemscript, logger.clone()),
1148+
onchain_tx_handler: OnchainTxHandler::new(destination_script.clone(), keys, funding_redeemscript, their_to_self_delay, logger.clone()),
11491149

11501150
last_block_hash: Default::default(),
11511151
secp_ctx: Secp256k1::new(),

lightning/src/ln/onchaintx.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
157157
prev_local_commitment: Option<LocalCommitmentTransaction>,
158158
current_htlc_cache: Option<HTLCTxCache>,
159159
prev_htlc_cache: Option<HTLCTxCache>,
160+
local_csv: u16,
160161

161162
key_storage: ChanSigner,
162163

@@ -230,6 +231,7 @@ impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
230231
} else {
231232
writer.write_all(&[0; 1])?;
232233
}
234+
self.local_csv.write(writer)?;
233235

234236
self.key_storage.write(writer)?;
235237

@@ -315,6 +317,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
315317
}
316318
_ => return Err(DecodeError::InvalidValue),
317319
};
320+
let local_csv = Readable::read(reader)?;
318321

319322
let key_storage = Readable::read(reader)?;
320323

@@ -368,6 +371,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
368371
prev_local_commitment,
369372
current_htlc_cache,
370373
prev_htlc_cache,
374+
local_csv,
371375
key_storage,
372376
claimable_outpoints,
373377
pending_claim_requests,
@@ -379,7 +383,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
379383
}
380384

381385
impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
382-
pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, logger: Arc<Logger>) -> Self {
386+
pub(super) fn new(destination_script: Script, keys: ChanSigner, funding_redeemscript: Script, local_csv: u16, logger: Arc<Logger>) -> Self {
383387

384388
let key_storage = keys;
385389

@@ -390,6 +394,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
390394
prev_local_commitment: None,
391395
current_htlc_cache: None,
392396
prev_htlc_cache: None,
397+
local_csv,
393398
key_storage,
394399
pending_claim_requests: HashMap::new(),
395400
claimable_outpoints: HashMap::new(),

0 commit comments

Comments
 (0)