lnd: verify proper keychain derivation version upon initial creation

This commit is contained in:
Olaoluwa Osuntokun 2018-03-06 11:55:10 -05:00
parent dc2404f289
commit 78cbe7a141
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

13
lnd.go
View File

@ -842,6 +842,17 @@ func waitForWalletPassword(grpcEndpoints, restEndpoints []string,
password := initMsg.Passphrase
cipherSeed := initMsg.WalletSeed
// Before we proceed, we'll check the internal version of the
// seed. If it's greater than the current key derivation
// version, then we'll return an error as we don't understand
// this.
if cipherSeed.InternalVersion != keychain.KeyDerivationVersion {
return nil, nil, fmt.Errorf("invalid internal seed "+
"version %v, current version is %v",
cipherSeed.InternalVersion,
keychain.KeyDerivationVersion)
}
netDir := btcwallet.NetworkDir(
chainConfig.ChainDir, activeNetParams.Params,
)
@ -850,9 +861,7 @@ func waitForWalletPassword(grpcEndpoints, restEndpoints []string,
// With the seed, we can now use the wallet loader to create
// the wallet, then unload it so it can be opened shortly
// after.
//
// TODO(roasbeef): extend loader to also accept birthday
// * also check with keychain version
_, err = loader.CreateNewWallet(
password, password, cipherSeed.Entropy[:],
)