Merge #12924: Fix hdmaster-key / seed-key confusion (scripted diff)

6249021d1 [docs] Add release notes for HD master key -> HD seed rename (John Newbery)
79053a5f2 [rpc] [wallet] Add 'hdmasterkeyid' alias return values. (John Newbery)
c75c35141 [refactor] manually change remaining instances of master key to seed. (John Newbery)
131d4450b scripted-diff: Rename master key to seed (John Newbery)

Pull request description:

  Addresses #12084 and #8684

  This renames a couple of functions and members (no functional changes, expect log prints):

  - Rename CKey::SetMaster to CKey::SetSeed
  - Rename CHDChain::masterKeyId to CHDChain::seedID
  - Rename CHDChain::hdMasterKeyID to CHDChain::hdSeedID
  - Rename CWallet::GenerateNewHDMasterKey to CWallet::GenerateNewHDSeed
  - Rename CWallet::SetHDMasterKey to CWallet::SetHDSeed

  As well it introduces a tiny API change:

  - RPC API change: Rename "hdmasterkeyid" to "hdseedid", rename "hdmaster" in wallet-dump output to "hdseed"

  Fixes also a bug:

  - Bugfix: use "s" instead of the incorrect "m" for the seed-key hd-keypath key metadata

Tree-SHA512: c913252636f213135a3b64df5de5d21844fb9c2d646567c1aad0ec65745188587de26119de99492c67e559bd49fdd9606b54276f00dddb84301785beba58f281
This commit is contained in:
Jonas Schnelli 2018-05-21 09:41:44 +02:00 committed by UdjinM6
parent ec9f526cec
commit 21bb444ad3
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9
7 changed files with 9 additions and 9 deletions

View File

@ -55,7 +55,7 @@ void CHDChain::Debug(const std::string& strName) const
std::cout << "seed: " << HexStr(vchSeed).c_str() << std::endl;
CExtKey extkey;
extkey.SetMaster(vchSeed.data(), vchSeed.size());
extkey.SetSeed(vchSeed.data(), vchSeed.size());
std::cout << "extended private masterkey: " << EncodeExtKey(extkey).c_str() << std::endl;
@ -167,7 +167,7 @@ void CHDChain::DeriveChildExtKey(uint32_t nAccountIndex, bool fInternal, uint32_
CExtKey changeKey; //key at m/purpose'/coin_type'/account'/change
CExtKey childKey; //key at m/purpose'/coin_type'/account'/change/address_index
masterKey.SetMaster(vchSeed.data(), vchSeed.size());
masterKey.SetSeed(vchSeed.data(), vchSeed.size());
// Use hardened derivation for purpose, coin_type and account
// (keys >= 0x80000000 are hardened after bip32)

View File

@ -273,7 +273,7 @@ bool CExtKey::Derive(CExtKey &out, unsigned int _nChild) const {
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
}
void CExtKey::SetMaster(const unsigned char *seed, unsigned int nSeedLen) {
void CExtKey::SetSeed(const unsigned char *seed, unsigned int nSeedLen) {
static const unsigned char hashkey[] = {'B','i','t','c','o','i','n',' ','s','e','e','d'};
std::vector<unsigned char, secure_allocator<unsigned char>> vout(64);
CHMAC_SHA512(hashkey, sizeof(hashkey)).Write(seed, nSeedLen).Finalize(vout.data());

View File

@ -158,7 +158,7 @@ struct CExtKey {
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE]);
bool Derive(CExtKey& out, unsigned int nChild) const;
CExtPubKey Neuter() const;
void SetMaster(const unsigned char* seed, unsigned int nSeedLen);
void SetSeed(const unsigned char* seed, unsigned int nSeedLen);
template <typename Stream>
void Serialize(Stream& s) const
{

View File

@ -91,7 +91,7 @@ static void RunTest(const TestVector &test) {
std::vector<unsigned char> seed = ParseHex(test.strHexMaster);
CExtKey key;
CExtPubKey pubkey;
key.SetMaster(seed.data(), seed.size());
key.SetSeed(seed.data(), seed.size());
pubkey = key.Neuter();
for (const TestDerivation &derive : test.vDerive) {
unsigned char data[74];

View File

@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(bip39_vectors)
CExtKey key;
CExtPubKey pubkey;
key.SetMaster(seed.data(), 64);
key.SetSeed(seed.data(), 64);
pubkey = key.Neuter();
// printf("CBitcoinExtKey: %s\n", EncodeExtKey(key).c_str());

View File

@ -939,7 +939,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
file << "# HD seed: " << HexStr(vchSeed) << "\n\n";
CExtKey masterKey;
masterKey.SetMaster(&vchSeed[0], vchSeed.size());
masterKey.SetSeed(&vchSeed[0], vchSeed.size());
file << "# extended private masterkey: " << EncodeExtKey(masterKey) << "\n";

View File

@ -34,10 +34,10 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
addr_keypath = comment.split(" addr=")[1]
addr = addr_keypath.split(" ")[0]
keypath = None
if keytype == "inactivehdmaster=1":
if keytype == "inactivehdseed=1":
# ensure the old master is still available
assert(hd_master_addr_old == addr)
elif keytype == "hdmaster=1":
elif keytype == "hdseed=1":
# ensure we have generated a new hd master key
assert(hd_master_addr_old != addr)
hd_master_addr_ret = addr