funding+lnd: make sure accessman won't interrupt funding flow

If there's an error occured when updating the peer's status after the
channel status is changed, we now make sure we log the error instead of
letting it interrupt the channel open/close flow.
This commit is contained in:
yyforyongyu committed 2025-06-19 16:05:59 +08:00
1 parent 0dc10ba692
commit 03de0f9e4b
3 files changed
+29 -51

No files matched your search

+12 -31
View File
@@ -511,7 +511,7 @@ type Config struct {
// NotifyOpenChannelEvent informs the ChannelNotifier when channels
// transition from pending open to open.
NotifyOpenChannelEvent func(wire.OutPoint, *btcec.PublicKey) error
NotifyOpenChannelEvent func(wire.OutPoint, *btcec.PublicKey)
// OpenChannelPredicate is a predicate on the lnwire.OpenChannel message
// and on the requesting node's public key that returns a bool which
@@ -521,13 +521,13 @@ type Config struct {
// NotifyPendingOpenChannelEvent informs the ChannelNotifier when
// channels enter a pending state.
NotifyPendingOpenChannelEvent func(wire.OutPoint,
*channeldb.OpenChannel, *btcec.PublicKey) error
*channeldb.OpenChannel, *btcec.PublicKey)
// NotifyFundingTimeout informs the ChannelNotifier when a pending-open
// channel times out because the funding transaction hasn't confirmed.
// This is only called for the fundee and only if the channel is
// zero-conf.
NotifyFundingTimeout func(wire.OutPoint, *btcec.PublicKey) error
NotifyFundingTimeout func(wire.OutPoint, *btcec.PublicKey)
// EnableUpfrontShutdown specifies whether the upfront shutdown script
// is enabled.
@@ -1319,13 +1319,9 @@ func (f *Manager) advancePendingChannelState(channel *channeldb.OpenChannel,
// Inform the ChannelNotifier that the channel has transitioned
// from pending open to open.
if err := f.cfg.NotifyOpenChannelEvent(
f.cfg.NotifyOpenChannelEvent(
channel.FundingOutpoint, channel.IdentityPub,
); err != nil {
log.Errorf("Unable to notify open channel event for "+
"ChannelPoint(%v): %v",
channel.FundingOutpoint, err)
}
)
// Find and close the discoverySignal for this channel such
// that ChannelReady messages will be processed.
@@ -2666,12 +2662,9 @@ func (f *Manager) fundeeProcessFundingCreated(peer lnpeer.Peer,
// Inform the ChannelNotifier that the channel has entered
// pending open state.
if err := f.cfg.NotifyPendingOpenChannelEvent(
f.cfg.NotifyPendingOpenChannelEvent(
fundingOut, completeChan, completeChan.IdentityPub,
); err != nil {
log.Errorf("Unable to send pending-open channel event for "+
"ChannelPoint(%v) %v", fundingOut, err)
}
)
// At this point we have sent our last funding message to the
// initiating peer before the funding transaction will be broadcast.
@@ -2891,13 +2884,9 @@ func (f *Manager) funderProcessFundingSigned(peer lnpeer.Peer,
case resCtx.updates <- upd:
// Inform the ChannelNotifier that the channel has entered
// pending open state.
if err := f.cfg.NotifyPendingOpenChannelEvent(
f.cfg.NotifyPendingOpenChannelEvent(
*fundingPoint, completeChan, completeChan.IdentityPub,
); err != nil {
log.Errorf("Unable to send pending-open channel "+
"event for ChannelPoint(%v) %v", fundingPoint,
err)
}
)
case <-f.quit:
return
@@ -2955,11 +2944,7 @@ func (f *Manager) fundingTimeout(c *channeldb.OpenChannel,
}
// Notify other subsystems about the funding timeout.
err := f.cfg.NotifyFundingTimeout(c.FundingOutpoint, c.IdentityPub)
if err != nil {
log.Errorf("failed to notify of funding timeout for "+
"ChanPoint(%v): %v", c.FundingOutpoint, err)
}
f.cfg.NotifyFundingTimeout(c.FundingOutpoint, c.IdentityPub)
timeoutErr := fmt.Errorf("timeout waiting for funding tx (%v) to "+
"confirm", c.FundingOutpoint)
@@ -3341,13 +3326,9 @@ func (f *Manager) handleFundingConfirmation(
// Inform the ChannelNotifier that the channel has transitioned from
// pending open to open.
if err := f.cfg.NotifyOpenChannelEvent(
f.cfg.NotifyOpenChannelEvent(
completeChan.FundingOutpoint, completeChan.IdentityPub,
); err != nil {
log.Errorf("Unable to notify open channel event for "+
"ChannelPoint(%v): %v", completeChan.FundingOutpoint,
err)
}
)
// Close the discoverySignal channel, indicating to a separate
// goroutine that the channel now is marked as open in the database
+3 -9
View File
@@ -232,29 +232,23 @@ type mockChanEvent struct {
}
func (m *mockChanEvent) NotifyOpenChannelEvent(outpoint wire.OutPoint,
remotePub *btcec.PublicKey) error {
remotePub *btcec.PublicKey) {
m.openEvent <- outpoint
return nil
}
func (m *mockChanEvent) NotifyPendingOpenChannelEvent(outpoint wire.OutPoint,
pendingChannel *channeldb.OpenChannel,
remotePub *btcec.PublicKey) error {
remotePub *btcec.PublicKey) {
m.pendingOpenEvent <- channelnotifier.PendingOpenChannelEvent{
ChannelPoint: &outpoint,
PendingChannel: pendingChannel,
}
return nil
}
func (m *mockChanEvent) NotifyFundingTimeout(outpoint wire.OutPoint,
remotePub *btcec.PublicKey) error {
return nil
remotePub *btcec.PublicKey) {
}
// mockZeroConfAcceptor always accepts the channel open request for zero-conf