Skip to content

Commit 7cb6525

Browse files
author
Antoine Riard
committed
Implement set_their_delayed_payment_base_key in ChannelMonitor
Needed to build redeemscript on HTLC-Success/HTLC-Timeout tx from remote revoked commitment tx
1 parent f71ff8f commit 7cb6525

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/ln/channel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ impl Channel {
563563
&chan_keys.htlc_base_key,
564564
BREAKDOWN_TIMEOUT, our_channel_monitor_claim_script);
565565
channel_monitor.set_their_htlc_base_key(&msg.htlc_basepoint);
566+
channel_monitor.set_their_delayed_payment_base_key(&msg.delayed_payment_basepoint);
566567
channel_monitor.set_their_to_self_delay(msg.to_self_delay);
567568

568569
let mut chan = Channel {
@@ -1226,6 +1227,7 @@ impl Channel {
12261227
// dust_limit_satoshis too small
12271228

12281229
self.channel_monitor.set_their_htlc_base_key(&msg.htlc_basepoint);
1230+
self.channel_monitor.set_their_delayed_payment_base_key(&msg.delayed_payment_basepoint);
12291231

12301232
self.their_dust_limit_satoshis = msg.dust_limit_satoshis;
12311233
self.their_max_htlc_value_in_flight_msat = cmp::min(msg.max_htlc_value_in_flight_msat, self.channel_value_satoshis * 1000);

src/ln/channelmonitor.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ pub struct ChannelMonitor {
166166
key_storage: KeyStorage,
167167
delayed_payment_base_key: PublicKey,
168168
their_htlc_base_key: Option<PublicKey>,
169+
their_delayed_payment_base_key: Option<PublicKey>,
169170
// first is the idx of the first of the two revocation points
170171
their_cur_revocation_points: Option<(u64, PublicKey, Option<PublicKey>)>,
171172

@@ -207,6 +208,7 @@ impl Clone for ChannelMonitor {
207208
key_storage: self.key_storage.clone(),
208209
delayed_payment_base_key: self.delayed_payment_base_key.clone(),
209210
their_htlc_base_key: self.their_htlc_base_key.clone(),
211+
their_delayed_payment_base_key: self.their_delayed_payment_base_key.clone(),
210212
their_cur_revocation_points: self.their_cur_revocation_points.clone(),
211213

212214
our_to_self_delay: self.our_to_self_delay,
@@ -238,6 +240,7 @@ impl PartialEq for ChannelMonitor {
238240
self.key_storage != other.key_storage ||
239241
self.delayed_payment_base_key != other.delayed_payment_base_key ||
240242
self.their_htlc_base_key != other.their_htlc_base_key ||
243+
self.their_delayed_payment_base_key != other.their_delayed_payment_base_key ||
241244
self.their_cur_revocation_points != other.their_cur_revocation_points ||
242245
self.our_to_self_delay != other.our_to_self_delay ||
243246
self.their_to_self_delay != other.their_to_self_delay ||
@@ -274,6 +277,7 @@ impl ChannelMonitor {
274277
},
275278
delayed_payment_base_key: delayed_payment_base_key.clone(),
276279
their_htlc_base_key: None,
280+
their_delayed_payment_base_key: None,
277281
their_cur_revocation_points: None,
278282

279283
our_to_self_delay: our_to_self_delay,
@@ -482,6 +486,10 @@ impl ChannelMonitor {
482486
self.their_htlc_base_key = Some(their_htlc_base_key.clone());
483487
}
484488

489+
pub(super) fn set_their_delayed_payment_base_key(&mut self, their_delayed_payment_base_key: &PublicKey) {
490+
self.their_delayed_payment_base_key = Some(their_delayed_payment_base_key.clone());
491+
}
492+
485493
pub(super) fn set_their_to_self_delay(&mut self, their_to_self_delay: u16) {
486494
self.their_to_self_delay = Some(their_to_self_delay);
487495
}
@@ -531,6 +539,7 @@ impl ChannelMonitor {
531539

532540
res.extend_from_slice(&self.delayed_payment_base_key.serialize());
533541
res.extend_from_slice(&self.their_htlc_base_key.as_ref().unwrap().serialize());
542+
res.extend_from_slice(&self.their_delayed_payment_base_key.as_ref().unwrap().serialize());
534543

535544
match self.their_cur_revocation_points {
536545
Some((idx, pubkey, second_option)) => {
@@ -705,6 +714,7 @@ impl ChannelMonitor {
705714

706715
let delayed_payment_base_key = unwrap_obj!(PublicKey::from_slice(&secp_ctx, read_bytes!(33)));
707716
let their_htlc_base_key = Some(unwrap_obj!(PublicKey::from_slice(&secp_ctx, read_bytes!(33))));
717+
let their_delayed_payment_base_key = Some(unwrap_obj!(PublicKey::from_slice(&secp_ctx, read_bytes!(33))));
708718

709719
let their_cur_revocation_points = {
710720
let first_idx = byte_utils::slice_to_be48(read_bytes!(6));
@@ -867,6 +877,7 @@ impl ChannelMonitor {
867877
key_storage,
868878
delayed_payment_base_key,
869879
their_htlc_base_key,
880+
their_delayed_payment_base_key,
870881
their_cur_revocation_points,
871882

872883
our_to_self_delay,

0 commit comments

Comments
 (0)