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"
|
flags "github.com/jessevdk/go-flags"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
||||||
@ -237,7 +238,13 @@ func lndMain() error {
|
|||||||
primaryChain := registeredChains.PrimaryChain()
|
primaryChain := registeredChains.PrimaryChain()
|
||||||
registeredChains.RegisterChain(primaryChain, activeChainControl)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -252,8 +259,9 @@ func lndMain() error {
|
|||||||
|
|
||||||
// Set up the core server which will listen for incoming peer
|
// Set up the core server which will listen for incoming peer
|
||||||
// connections.
|
// connections.
|
||||||
server, err := newServer(cfg.Listeners, chanDB, activeChainControl,
|
server, err := newServer(
|
||||||
idPrivKey)
|
cfg.Listeners, chanDB, activeChainControl, idPrivKey,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
srvrLog.Errorf("unable to create server: %v\n", err)
|
srvrLog.Errorf("unable to create server: %v\n", err)
|
||||||
return err
|
return err
|
||||||
|
3
mock.go
3
mock.go
@ -203,8 +203,7 @@ func (*mockWalletController) FetchInputInfo(
|
|||||||
}
|
}
|
||||||
return txOut, nil
|
return txOut, nil
|
||||||
}
|
}
|
||||||
func (*mockWalletController) ConfirmedBalance(confs int32,
|
func (*mockWalletController) ConfirmedBalance(confs int32) (btcutil.Amount, error) {
|
||||||
witness bool) (btcutil.Amount, error) {
|
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
pilot.go
2
pilot.go
@ -146,7 +146,7 @@ func initAutoPilot(svr *server, cfg *autoPilotConfig) (*autopilot.Agent, error)
|
|||||||
Heuristic: prefAttachment,
|
Heuristic: prefAttachment,
|
||||||
ChanController: &chanController{svr},
|
ChanController: &chanController{svr},
|
||||||
WalletBalance: func() (btcutil.Amount, error) {
|
WalletBalance: func() (btcutil.Amount, error) {
|
||||||
return svr.cc.wallet.ConfirmedBalance(1, true)
|
return svr.cc.wallet.ConfirmedBalance(1)
|
||||||
},
|
},
|
||||||
Graph: autopilot.ChannelGraphFromDatabase(svr.chanDB.ChannelGraph()),
|
Graph: autopilot.ChannelGraphFromDatabase(svr.chanDB.ChannelGraph()),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user