mirror of https://github.com/BTCPrivate/lnd.git
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 broadcasts the passed transaction to the network.
|
||||||
broadcastTx func(*wire.MsgTx) error
|
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
|
// quit is a channel that should be sent upon in the occasion the state
|
||||||
// machine shouldk cease all progress and shutdown.
|
// machine shouldk cease all progress and shutdown.
|
||||||
quit chan struct{}
|
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
|
// Clear out the current channel state, marking the channel as
|
||||||
// being closed within the database.
|
// being closed within the database.
|
||||||
closingTxid := closeTx.TxHash()
|
closingTxid := closeTx.TxHash()
|
||||||
|
|
|
@ -169,6 +169,12 @@ type fundingConfig struct {
|
||||||
// so that the channel creation process can be completed.
|
// so that the channel creation process can be completed.
|
||||||
Notifier chainntnfs.ChainNotifier
|
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
|
// SignMessage signs an arbitrary method with a given public key. The
|
||||||
// actual digest signed is the double sha-256 of the message. In 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
|
// case that the private key corresponding to the passed public key
|
||||||
|
@ -1984,6 +1990,15 @@ func (f *fundingManager) handleFundingLocked(fmsg *fundingLockedMsg) {
|
||||||
return
|
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
|
// The funding locked message contains the next commitment point we'll
|
||||||
// need to create the next commitment state for the remote party. So
|
// 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
|
// 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())
|
idPrivKey.PubKey())
|
||||||
return <-errChan
|
return <-errChan
|
||||||
},
|
},
|
||||||
|
ArbiterChan: server.breachArbiter.newContracts,
|
||||||
SendToPeer: server.SendToPeer,
|
SendToPeer: server.SendToPeer,
|
||||||
NotifyWhenOnline: server.NotifyWhenOnline,
|
NotifyWhenOnline: server.NotifyWhenOnline,
|
||||||
FindPeer: server.FindPeer,
|
FindPeer: server.FindPeer,
|
||||||
|
|
4
peer.go
4
peer.go
|
@ -382,7 +382,6 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
|
||||||
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
|
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
|
||||||
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
|
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
|
||||||
p.PubKey(), lnChan.ShortChanID()),
|
p.PubKey(), lnChan.ShortChanID()),
|
||||||
SettledContracts: p.server.breachArbiter.settledContracts,
|
|
||||||
DebugHTLC: cfg.DebugHTLC,
|
DebugHTLC: cfg.DebugHTLC,
|
||||||
HodlHTLC: cfg.HodlHTLC,
|
HodlHTLC: cfg.HodlHTLC,
|
||||||
Registry: p.server.invoices,
|
Registry: p.server.invoices,
|
||||||
|
@ -1275,7 +1274,6 @@ out:
|
||||||
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
|
DecodeOnionObfuscator: p.server.sphinx.ExtractErrorEncrypter,
|
||||||
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
|
GetLastChannelUpdate: createGetLastUpdate(p.server.chanRouter,
|
||||||
p.PubKey(), newChanReq.channel.ShortChanID()),
|
p.PubKey(), newChanReq.channel.ShortChanID()),
|
||||||
SettledContracts: p.server.breachArbiter.settledContracts,
|
|
||||||
DebugHTLC: cfg.DebugHTLC,
|
DebugHTLC: cfg.DebugHTLC,
|
||||||
HodlHTLC: cfg.HodlHTLC,
|
HodlHTLC: cfg.HodlHTLC,
|
||||||
Registry: p.server.invoices,
|
Registry: p.server.invoices,
|
||||||
|
@ -1446,7 +1444,6 @@ func (p *peer) fetchActiveChanCloser(chanID lnwire.ChannelID) (*channelCloser, e
|
||||||
channel: channel,
|
channel: channel,
|
||||||
unregisterChannel: p.server.htlcSwitch.RemoveLink,
|
unregisterChannel: p.server.htlcSwitch.RemoveLink,
|
||||||
broadcastTx: p.server.cc.wallet.PublishTransaction,
|
broadcastTx: p.server.cc.wallet.PublishTransaction,
|
||||||
settledContracts: p.server.breachArbiter.settledContracts,
|
|
||||||
quit: p.quit,
|
quit: p.quit,
|
||||||
},
|
},
|
||||||
deliveryAddr,
|
deliveryAddr,
|
||||||
|
@ -1523,7 +1520,6 @@ func (p *peer) handleLocalCloseReq(req *htlcswitch.ChanClose) {
|
||||||
channel: channel,
|
channel: channel,
|
||||||
unregisterChannel: p.server.htlcSwitch.RemoveLink,
|
unregisterChannel: p.server.htlcSwitch.RemoveLink,
|
||||||
broadcastTx: p.server.cc.wallet.PublishTransaction,
|
broadcastTx: p.server.cc.wallet.PublishTransaction,
|
||||||
settledContracts: p.server.breachArbiter.settledContracts,
|
|
||||||
quit: p.quit,
|
quit: p.quit,
|
||||||
},
|
},
|
||||||
deliveryAddr,
|
deliveryAddr,
|
||||||
|
|
|
@ -847,7 +847,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case r.server.breachArbiter.settledContracts <- chanPoint:
|
case r.server.breachArbiter.settledContracts <- *chanPoint:
|
||||||
case <-r.quit:
|
case <-r.quit:
|
||||||
return fmt.Errorf("server shutting down")
|
return fmt.Errorf("server shutting down")
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,9 +248,7 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
|
||||||
wallet: wallet,
|
wallet: wallet,
|
||||||
}
|
}
|
||||||
|
|
||||||
breachArbiter := &breachArbiter{
|
breachArbiter := &breachArbiter{}
|
||||||
settledContracts: make(chan *wire.OutPoint, 10),
|
|
||||||
}
|
|
||||||
|
|
||||||
chainArb := contractcourt.NewChainArbitrator(
|
chainArb := contractcourt.NewChainArbitrator(
|
||||||
contractcourt.ChainArbitratorConfig{}, nil,
|
contractcourt.ChainArbitratorConfig{}, nil,
|
||||||
|
|
Loading…
Reference in New Issue