Skip to content

Commit 734452c

Browse files
committed
Request announcement_signatures retransmission
During channel reestablishment, announcement_signatures may need to be retransmitted. The splicing spec allows doing so without retransmitting splice_locked first, which could normally trigger retransmitting announcement_signatures. Instead, my_current_funding_locked lets the sender request retransmitting it.
1 parent d4ddbc4 commit 734452c

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11067,7 +11067,25 @@ where
1106711067
.or_else(|| {
1106811068
self.is_our_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
1106911069
})
11070-
.map(|txid| msgs::FundingLocked { txid, retransmit_flags: 0 })
11070+
.map(|txid| {
11071+
let mut funding_locked = msgs::FundingLocked { txid, retransmit_flags: 0 };
11072+
11073+
// - if `my_current_funding_locked` is included:
11074+
// - if `announce_channel` is set for this channel:
11075+
// - if it has not received `announcement_signatures` for that transaction:
11076+
// - MUST set the `announcement_signatures` bit to `1` in `retransmit_flags`.
11077+
// - otherwise:
11078+
// - MUST set the `announcement_signatures` bit to `0` in `retransmit_flags`.
11079+
if self.context.config.announce_for_forwarding {
11080+
if self.funding.get_funding_txid() != Some(txid)
11081+
|| self.context.announcement_sigs.is_none()
11082+
{
11083+
funding_locked.retransmit(msgs::FundingLockedFlags::AnnouncementSignatures);
11084+
}
11085+
}
11086+
11087+
funding_locked
11088+
})
1107111089
}
1107211090

1107311091
#[cfg(not(splicing))]

lightning/src/ln/msgs.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,12 +976,24 @@ pub struct FundingLocked {
976976

977977
/// A bitfield indicating which messages should be retransmitted by the receiving node.
978978
///
979-
/// | Bit Position | Name |
980-
/// | ------------- | --------------------------|
981-
/// | 0 | `announcement_signatures` |
979+
/// See [`FundingLockedFlags`] for details.
982980
pub retransmit_flags: u8,
983981
}
984982

983+
impl FundingLocked {
984+
/// Sets the bit in `retransmit_flags` for retransmitting the message corresponding to `flag`.
985+
pub fn retransmit(&mut self, flag: FundingLockedFlags) {
986+
self.retransmit_flags |= 1 << flag as u8;
987+
}
988+
}
989+
990+
/// Bit positions used in [`FundingLocked::retransmit_flags`] for requesting message retransmission.
991+
#[repr(u8)]
992+
pub enum FundingLockedFlags {
993+
/// Retransmit `announcement_signatures`.
994+
AnnouncementSignatures = 0,
995+
}
996+
985997
/// An [`announcement_signatures`] message to be sent to or received from a peer.
986998
///
987999
/// [`announcement_signatures`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-announcement_signatures-message

0 commit comments

Comments
 (0)