peer+htlcswitch: inject notification endpoint
What changed, and why it matters
This commit adds a new notification hook so the channel link can tell other parts of the program when a channel's state has been updated. It is purely an infrastructure/plumbing change: it wires up a new callback but does not change any existing security behavior, validation, or access control. There is no indication this fixes or introduces a vulnerability.
No security action required. Review as normal code-quality/plumbing change.
Security signals we found
No security-relevant behavior changed
No validation or access-control logic modified
No bug fix or vulnerability remediation described
New callback is not invoked in the diff
Evidence from the diff
The change introduces a NotifyChannelUpdate callback in ChannelLinkConfig and wires it to ChannelNotifier.NotifyChannelUpdateEvent in peer/brontide.go. Test harnesses are updated to provide no-op implementations. The callback is not invoked anywhere in this commit; it only makes the endpoint available for future use. No logic, state machine, or cryptographic checks are modified.
Changed components
htlcswitch/link.gohtlcswitch/link_test.gohtlcswitch/test_utils.gopeer/brontide.goInspect captured patch +8 / −0
diff --git a/htlcswitch/link.go b/htlcswitch/link.go
index 4dbfa52..f67d4b4 100644
--- a/htlcswitch/link.go
+++ b/htlcswitch/link.go
@@ -256,6 +256,10 @@ type ChannelLinkConfig struct {
// ChannelNotifier when a channel link become inactive.
NotifyInactiveLinkEvent func(wire.OutPoint)
+ // NotifyChannelUpdate allows the link to tell the ChannelNotifier when
+ // a channel's state has been updated.
+ NotifyChannelUpdate func(*channeldb.OpenChannel)
+
// HtlcNotifier is an instance of a htlcNotifier which we will pipe htlc
// events through.
HtlcNotifier htlcNotifier
diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go
index e4e63d9..29b4f90 100644
--- a/htlcswitch/link_test.go
+++ b/htlcswitch/link_test.go
@@ -2241,6 +2241,7 @@ func newSingleLinkTestHarness(t *testing.T, chanAmt,
MaxFeeAllocation: DefaultMaxLinkFeeAllocation,
NotifyActiveLink: func(wire.OutPoint) {},
NotifyActiveChannel: func(wire.OutPoint) {},
+ NotifyChannelUpdate: func(*channeldb.OpenChannel) {},
NotifyInactiveChannel: func(wire.OutPoint) {},
NotifyInactiveLinkEvent: func(wire.OutPoint) {},
HtlcNotifier: aliceSwitch.cfg.HtlcNotifier,
@@ -4931,6 +4932,7 @@ func (h *persistentLinkHarness) restartLink(
NotifyActiveChannel: func(wire.OutPoint) {},
NotifyInactiveChannel: func(wire.OutPoint) {},
NotifyInactiveLinkEvent: func(wire.OutPoint) {},
+ NotifyChannelUpdate: func(*channeldb.OpenChannel) {},
HtlcNotifier: h.hSwitch.cfg.HtlcNotifier,
SyncStates: syncStates,
GetAliases: getAliases,
diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go
index b74dbd0..2e08425 100644
--- a/htlcswitch/test_utils.go
+++ b/htlcswitch/test_utils.go
@@ -1175,6 +1175,7 @@ func (h *hopNetwork) createChannelLink(server, peer *mockServer,
NotifyActiveChannel: func(wire.OutPoint) {},
NotifyInactiveChannel: func(wire.OutPoint) {},
NotifyInactiveLinkEvent: func(wire.OutPoint) {},
+ NotifyChannelUpdate: func(*channeldb.OpenChannel) {},
HtlcNotifier: server.htlcSwitch.cfg.HtlcNotifier,
GetAliases: getAliases,
ShouldFwdExpAccountability: func() bool { return true },
diff --git a/peer/brontide.go b/peer/brontide.go
index 72ee887..d92f9c4 100644
--- a/peer/brontide.go
+++ b/peer/brontide.go
@@ -1480,6 +1480,7 @@ func (p *Brontide) addLink(chanPoint *wire.OutPoint,
NotifyActiveChannel: p.cfg.ChannelNotifier.NotifyActiveChannelEvent,
NotifyInactiveChannel: p.cfg.ChannelNotifier.NotifyInactiveChannelEvent,
NotifyInactiveLinkEvent: p.cfg.ChannelNotifier.NotifyInactiveLinkEvent,
+ NotifyChannelUpdate: p.cfg.ChannelNotifier.NotifyChannelUpdateEvent,
HtlcNotifier: p.cfg.HtlcNotifier,
GetAliases: p.cfg.GetAliases,
PreviouslySentShutdown: shutdownMsg,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.