lnd: use first key in keychain.KeyFamilyNodeKey as our nodeID
In this commit, we update lnd to now access the deterministic keychain.KeyRing struct in order to obtain our identity public key. With this change, if the user recovers their wallet with the same seed, then they’ll have access to the same prior node identity. This change also makes it easy for us to support node key rotation in the future by bumping up our requested index.
This commit is contained in:
parent
b41222b316
commit
1669e3d5ec
14
lnd.go
14
lnd.go
@ -37,6 +37,7 @@ import (
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
"github.com/lightningnetwork/lnd/autopilot"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
||||
@ -237,7 +238,13 @@ func lndMain() error {
|
||||
primaryChain := registeredChains.PrimaryChain()
|
||||
registeredChains.RegisterChain(primaryChain, activeChainControl)
|
||||
|
||||
idPrivKey, err := activeChainControl.wallet.GetIdentitykey()
|
||||
// TODO(roasbeef): add rotation
|
||||
idPrivKey, err := activeChainControl.wallet.DerivePrivKey(keychain.KeyDescriptor{
|
||||
KeyLocator: keychain.KeyLocator{
|
||||
Family: keychain.KeyFamilyNodeKey,
|
||||
Index: 0,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -252,8 +259,9 @@ func lndMain() error {
|
||||
|
||||
// Set up the core server which will listen for incoming peer
|
||||
// connections.
|
||||
server, err := newServer(cfg.Listeners, chanDB, activeChainControl,
|
||||
idPrivKey)
|
||||
server, err := newServer(
|
||||
cfg.Listeners, chanDB, activeChainControl, idPrivKey,
|
||||
)
|
||||
if err != nil {
|
||||
srvrLog.Errorf("unable to create server: %v\n", err)
|
||||
return err
|
||||
|
3
mock.go
3
mock.go
@ -203,8 +203,7 @@ func (*mockWalletController) FetchInputInfo(
|
||||
}
|
||||
return txOut, nil
|
||||
}
|
||||
func (*mockWalletController) ConfirmedBalance(confs int32,
|
||||
witness bool) (btcutil.Amount, error) {
|
||||
func (*mockWalletController) ConfirmedBalance(confs int32) (btcutil.Amount, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
|
2
pilot.go
2
pilot.go
@ -146,7 +146,7 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
|
||||
Heuristic: prefAttachment,
|
||||
ChanController: &chanController{svr},
|
||||
WalletBalance: func() (btcutil.Amount, error) {
|
||||
return svr.cc.wallet.ConfirmedBalance(1, true)
|
||||
return svr.cc.wallet.ConfirmedBalance(1)
|
||||
},
|
||||
Graph: autopilot.ChannelGraphFromDatabase(svr.chanDB.ChannelGraph()),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user