contractcourt/chain_arbitrator: notify the ChannelNotifier on newly closed channels.
This commit is contained in:
parent
bdd8ce14c9
commit
10090a978d
@ -141,6 +141,10 @@ type ChainArbitratorConfig struct {
|
||||
// the given payment hash. ErrInvoiceNotFound is returned if an invoice
|
||||
// is not found.
|
||||
SettleInvoice func(lntypes.Hash, lnwire.MilliSatoshi) error
|
||||
|
||||
// NotifyClosedChannel is a function closure that the ChainArbitrator
|
||||
// will use to notify the ChannelNotifier about a newly closed channel.
|
||||
NotifyClosedChannel func(wire.OutPoint)
|
||||
}
|
||||
|
||||
// ChainArbitrator is a sub-system that oversees the on-chain resolution of all
|
||||
@ -245,7 +249,13 @@ func newActiveChannelArbitrator(channel *channeldb.OpenChannel,
|
||||
return chanMachine.ForceClose()
|
||||
},
|
||||
MarkCommitmentBroadcasted: channel.MarkCommitmentBroadcasted,
|
||||
MarkChannelClosed: channel.CloseChannel,
|
||||
MarkChannelClosed: func(summary *channeldb.ChannelCloseSummary) error {
|
||||
if err := channel.CloseChannel(summary); err != nil {
|
||||
return err
|
||||
}
|
||||
c.cfg.NotifyClosedChannel(summary.ChanPoint)
|
||||
return nil
|
||||
},
|
||||
IsPendingClose: false,
|
||||
ChainArbitratorConfig: c.cfg,
|
||||
ChainEvents: chanEvents,
|
||||
@ -719,13 +729,7 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error
|
||||
// SubscribeChannelEvents returns a new active subscription for the set of
|
||||
// possible on-chain events for a particular channel. The struct can be used by
|
||||
// callers to be notified whenever an event that changes the state of the
|
||||
// channel on-chain occurs. If syncDispatch is true, then the sender of the
|
||||
// notification will wait until an error is sent over the ProcessACK before
|
||||
// modifying any database state. This allows callers to request a reliable hand
|
||||
// off.
|
||||
//
|
||||
// TODO(roasbeef): can be used later to provide RPC hook for all channel
|
||||
// lifetimes
|
||||
// channel on-chain occurs.
|
||||
func (c *ChainArbitrator) SubscribeChannelEvents(
|
||||
chanPoint wire.OutPoint) (*ChainEventSubscription, error) {
|
||||
|
||||
|
@ -744,6 +744,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, cc *chainControl,
|
||||
},
|
||||
Sweeper: s.sweeper,
|
||||
SettleInvoice: s.invoices.SettleInvoice,
|
||||
NotifyClosedChannel: s.channelNotifier.NotifyClosedChannelEvent,
|
||||
}, chanDB)
|
||||
|
||||
s.breachArbiter = newBreachArbiter(&BreachConfig{
|
||||
|
Loading…
Reference in New Issue
Block a user