mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
peer: the chancloser no longer needs to notify the breach arb of settled transactions
This commit is contained in:
parent
73641d222f
commit
d4e650c85d
@ -82,11 +82,6 @@ type chanCloseCfg struct {
|
||||
// broadcastTx broadcasts the passed transaction to the network.
|
||||
broadcastTx func(*wire.MsgTx) error
|
||||
|
||||
// settledContracts is a channel that will be sent upon once the
|
||||
// channel is partially closed. This notifies any sub-systems that they
|
||||
// no longer need to watch the channel for any on-chain activity.
|
||||
settledContracts chan<- *wire.OutPoint
|
||||
|
||||
// quit is a channel that should be sent upon in the occasion the state
|
||||
// machine shouldk cease all progress and shutdown.
|
||||
quit chan struct{}
|
||||
@ -452,14 +447,6 @@ func (c *channelCloser) ProcessCloseMsg(msg lnwire.Message) ([]lnwire.Message, b
|
||||
}
|
||||
}
|
||||
|
||||
// As this contract is final, we'll send it over the settled
|
||||
// contracts channel.
|
||||
select {
|
||||
case c.cfg.settledContracts <- &c.chanPoint:
|
||||
case <-c.cfg.quit:
|
||||
return nil, false, fmt.Errorf("peer shutting down")
|
||||
}
|
||||
|
||||
// Clear out the current channel state, marking the channel as
|
||||
// being closed within the database.
|
||||
closingTxid := closeTx.TxHash()
|
||||
|
@ -169,6 +169,12 @@ type fundingConfig struct {
|
||||
// so that the channel creation process can be completed.
|
||||
Notifier chainntnfs.ChainNotifier
|
||||
|
||||
// ArbiterChan allows the FundingManager to notify the BreachArbiter
|
||||
// that a new channel has been created that should be observed to
|
||||
// ensure that the channel counterparty hasn't broadcast an invalid
|
||||
// commitment transaction.
|
||||
ArbiterChan chan<- wire.OutPoint
|
||||
|
||||
// SignMessage signs an arbitrary method with a given public key. The
|
||||
// actual digest signed is the double sha-256 of the message. In the
|
||||
// case that the private key corresponding to the passed public key
|
||||
@ -1984,6 +1990,15 @@ func (f *fundingManager) handleFundingLocked(fmsg *fundingLockedMsg) {
|
||||
return
|
||||
}
|
||||
|
||||
// With the channel retrieved, we'll send the breach arbiter the new
|
||||
// channel so it can watch for attempts to breach the channel's
|
||||
// contract by the remote party.
|
||||
select {
|
||||
case f.cfg.ArbiterChan <- *channel.ChanPoint:
|
||||
case <-f.quit:
|
||||
return
|
||||
}
|
||||
|
||||
// The funding locked message contains the next commitment point we'll
|
||||
// need to create the next commitment state for the remote party. So
|
||||
// we'll insert that into the channel now before passing it along to
|
||||
|
1
lnd.go
1
lnd.go
@ -268,6 +268,7 @@ func lndMain() error {
|
||||
idPrivKey.PubKey())
|
||||
return <-errChan
|
||||
},
|
||||
ArbiterChan: server.breachArbiter.newContracts,
|
||||
SendToPeer: server.SendToPeer,
|
||||
NotifyWhenOnline: server.NotifyWhenOnline,
|
||||
FindPeer: server.FindPeer,
|
||||
|
40
peer.go
40
peer.go
@ -382,16 +382,15 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
||||
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
|
||||
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
|
||||
p.PubKey(), lnChan.ShortChanID()),
|
||||
SettledContracts: p.server.breachArbiter.settledContracts,
|
||||
DebugHTLC: cfg.DebugHTLC,
|
||||
HodlHTLC: cfg.HodlHTLC,
|
||||
Registry: p.server.invoices,
|
||||
Switch: p.server.htlcSwitch,
|
||||
FwrdingPolicy: *forwardingPolicy,
|
||||
FeeEstimator: p.server.cc.feeEstimator,
|
||||
BlockEpochs: blockEpoch,
|
||||
PreimageCache: p.server.witnessBeacon,
|
||||
ChainEvents: chainEvents,
|
||||
DebugHTLC: cfg.DebugHTLC,
|
||||
HodlHTLC: cfg.HodlHTLC,
|
||||
Registry: p.server.invoices,
|
||||
Switch: p.server.htlcSwitch,
|
||||
FwrdingPolicy: *forwardingPolicy,
|
||||
FeeEstimator: p.server.cc.feeEstimator,
|
||||
BlockEpochs: blockEpoch,
|
||||
PreimageCache: p.server.witnessBeacon,
|
||||
ChainEvents: chainEvents,
|
||||
UpdateContractSignals: func(signals *contractcourt.ContractSignals) error {
|
||||
return p.server.chainArb.UpdateContractSignals(
|
||||
*chanPoint, signals,
|
||||
@ -1275,16 +1274,15 @@ out:
|
||||
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
|
||||
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
|
||||
p.PubKey(), newChanReq.channel.ShortChanID()),
|
||||
SettledContracts: p.server.breachArbiter.settledContracts,
|
||||
DebugHTLC: cfg.DebugHTLC,
|
||||
HodlHTLC: cfg.HodlHTLC,
|
||||
Registry: p.server.invoices,
|
||||
Switch: p.server.htlcSwitch,
|
||||
FwrdingPolicy: p.server.cc.routingPolicy,
|
||||
FeeEstimator: p.server.cc.feeEstimator,
|
||||
BlockEpochs: blockEpoch,
|
||||
PreimageCache: p.server.witnessBeacon,
|
||||
ChainEvents: chainEvents,
|
||||
DebugHTLC: cfg.DebugHTLC,
|
||||
HodlHTLC: cfg.HodlHTLC,
|
||||
Registry: p.server.invoices,
|
||||
Switch: p.server.htlcSwitch,
|
||||
FwrdingPolicy: p.server.cc.routingPolicy,
|
||||
FeeEstimator: p.server.cc.feeEstimator,
|
||||
BlockEpochs: blockEpoch,
|
||||
PreimageCache: p.server.witnessBeacon,
|
||||
ChainEvents: chainEvents,
|
||||
UpdateContractSignals: func(signals *contractcourt.ContractSignals) error {
|
||||
return p.server.chainArb.UpdateContractSignals(
|
||||
*chanPoint, signals,
|
||||
@ -1446,7 +1444,6 @@ func (p *peer) fetchActiveChanCloser(chanID lnwire.ChannelID) (*channelCloser, e
|
||||
channel: channel,
|
||||
unregisterChannel: p.server.htlcSwitch.RemoveLink,
|
||||
broadcastTx: p.server.cc.wallet.PublishTransaction,
|
||||
settledContracts: p.server.breachArbiter.settledContracts,
|
||||
quit: p.quit,
|
||||
},
|
||||
deliveryAddr,
|
||||
@ -1523,7 +1520,6 @@ func (p *peer) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
||||
channel: channel,
|
||||
unregisterChannel: p.server.htlcSwitch.RemoveLink,
|
||||
broadcastTx: p.server.cc.wallet.PublishTransaction,
|
||||
settledContracts: p.server.breachArbiter.settledContracts,
|
||||
quit: p.quit,
|
||||
},
|
||||
deliveryAddr,
|
||||
|
@ -847,7 +847,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
}
|
||||
|
||||
select {
|
||||
case r.server.breachArbiter.settledContracts <- chanPoint:
|
||||
case r.server.breachArbiter.settledContracts <- *chanPoint:
|
||||
case <-r.quit:
|
||||
return fmt.Errorf("server shutting down")
|
||||
}
|
||||
|
@ -248,9 +248,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
|
||||
wallet: wallet,
|
||||
}
|
||||
|
||||
breachArbiter := &breachArbiter{
|
||||
settledContracts: make(chan *wire.OutPoint, 10),
|
||||
}
|
||||
breachArbiter := &breachArbiter{}
|
||||
|
||||
chainArb := contractcourt.NewChainArbitrator(
|
||||
contractcourt.ChainArbitratorConfig{}, nil,
|
||||
|
Loading…
Reference in New Issue
Block a user