fundingmanager+lnd: modify WatchNewChannel callback to take in peer key

This commit is contained in:
Wilmer Paulino
2018-07-05 13:28:57 -07:00
parent 3ab17063ff
commit 6b1982f50f
2 changed files with 6 additions and 8 deletions

View File

@ -324,9 +324,9 @@ type fundingConfig struct {
// WatchNewChannel is to be called once a new channel enters the final // WatchNewChannel is to be called once a new channel enters the final
// funding stage: waiting for on-chain confirmation. This method sends // funding stage: waiting for on-chain confirmation. This method sends
// the channel to the ChainArbitrator so it can watch for any on-chain // the channel to the ChainArbitrator so it can watch for any on-chain
// events related to the channel. We also provide the address of the // events related to the channel. We also provide the public key of the
// node we're establishing a channel with for reconnection purposes. // node we're establishing a channel with for reconnection purposes.
WatchNewChannel func(*channeldb.OpenChannel, *lnwire.NetAddress) error WatchNewChannel func(*channeldb.OpenChannel, *btcec.PublicKey) error
// ReportShortChanID allows the funding manager to report the newly // ReportShortChanID allows the funding manager to report the newly
// discovered short channel ID of a formerly pending channel to outside // discovered short channel ID of a formerly pending channel to outside
@ -1401,8 +1401,7 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) {
// Now that we've sent over our final signature for this channel, we'll // Now that we've sent over our final signature for this channel, we'll
// send it to the ChainArbitrator so it can watch for any on-chain // send it to the ChainArbitrator so it can watch for any on-chain
// actions during this final confirmation stage. // actions during this final confirmation stage.
peerAddr := resCtx.peerAddress if err := f.cfg.WatchNewChannel(completeChan, peerKey); err != nil {
if err := f.cfg.WatchNewChannel(completeChan, peerAddr); err != nil {
fndgLog.Errorf("Unable to send new ChannelPoint(%v) for "+ fndgLog.Errorf("Unable to send new ChannelPoint(%v) for "+
"arbitration: %v", fundingOut, err) "arbitration: %v", fundingOut, err)
} }
@ -1553,8 +1552,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
// we'll send the to be active channel to the ChainArbitrator so it can // we'll send the to be active channel to the ChainArbitrator so it can
// watch for any on-chin actions before the channel has fully // watch for any on-chin actions before the channel has fully
// confirmed. // confirmed.
peerAddr := resCtx.peerAddress if err := f.cfg.WatchNewChannel(completeChan, peerKey); err != nil {
if err := f.cfg.WatchNewChannel(completeChan, peerAddr); err != nil {
fndgLog.Errorf("Unable to send new ChannelPoint(%v) for "+ fndgLog.Errorf("Unable to send new ChannelPoint(%v) for "+
"arbitration: %v", fundingPoint, err) "arbitration: %v", fundingPoint, err)
} }

4
lnd.go
View File

@ -450,12 +450,12 @@ func lndMain() error {
return delay return delay
}, },
WatchNewChannel: func(channel *channeldb.OpenChannel, WatchNewChannel: func(channel *channeldb.OpenChannel,
addr *lnwire.NetAddress) error { peerKey *btcec.PublicKey) error {
// First, we'll mark this new peer as a persistent peer // First, we'll mark this new peer as a persistent peer
// for re-connection purposes. // for re-connection purposes.
server.mu.Lock() server.mu.Lock()
pubStr := string(addr.IdentityKey.SerializeCompressed()) pubStr := string(peerKey.SerializeCompressed())
server.persistentPeers[pubStr] = struct{}{} server.persistentPeers[pubStr] = struct{}{}
server.mu.Unlock() server.mu.Unlock()