[Wallet] comsetic non-code changes for the HD feature

This commit is contained in:
Jonas Schnelli 2016-07-15 10:34:08 +02:00
parent 68d7682b9f
commit 7945088d41
No known key found for this signature in database
GPG key ID: 29D4BCB6416F53EC
4 changed files with 9 additions and 9 deletions

View file

@ -47,10 +47,10 @@ class WalletHDTest(BitcoinTestFramework):
self.nodes[0].generate(101) self.nodes[0].generate(101)
hd_add = None hd_add = None
num_hd_adds = 300 num_hd_adds = 300
for _ in range(num_hd_adds): for i in range(num_hd_adds):
hd_add = self.nodes[1].getnewaddress() hd_add = self.nodes[1].getnewaddress()
hd_info = self.nodes[1].validateaddress(hd_add) hd_info = self.nodes[1].validateaddress(hd_add)
assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(_+1)+"'") assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(i+1)+"'")
assert_equal(hd_info["hdmasterkeyid"], masterkeyid) assert_equal(hd_info["hdmasterkeyid"], masterkeyid)
self.nodes[0].sendtoaddress(hd_add, 1) self.nodes[0].sendtoaddress(hd_add, 1)
self.nodes[0].generate(1) self.nodes[0].generate(1)

View file

@ -2269,7 +2269,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp)
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n"
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
" \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n" " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
" \"masterkeyid\": \"<hash160>\", (string) the Hash160 of the hd master pubkey\n" " \"masterkeyid\": \"<hash160>\", (string) the Hash160 of the HD master pubkey\n"
"}\n" "}\n"
"\nExamples:\n" "\nExamples:\n"
+ HelpExampleCli("getwalletinfo", "") + HelpExampleCli("getwalletinfo", "")
@ -2291,7 +2291,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID; CKeyID masterKeyID = pwalletMain->GetHDChain().masterKeyID;
if (!masterKeyID.IsNull()) if (!masterKeyID.IsNull())
obj.push_back(Pair("masterkeyid",masterKeyID.GetHex())); obj.push_back(Pair("masterkeyid", masterKeyID.GetHex()));
return obj; return obj;
} }

View file

@ -577,7 +577,7 @@ private:
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>); void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>);
/* the hd chain data model (external chain counters) */ /* the HD chain data model (external chain counters) */
CHDChain hdChain; CHDChain hdChain;
public: public:
@ -896,10 +896,10 @@ public:
bool BackupWallet(const std::string& strDest); bool BackupWallet(const std::string& strDest);
/* Set the hd chain model (chain child index counters) */ /* Set the HD chain model (chain child index counters) */
bool SetHDChain(const CHDChain& chain, bool memonly); bool SetHDChain(const CHDChain& chain, bool memonly);
/* Set the current hd master key (will reset the chain child index counters) */ /* Set the current HD master key (will reset the chain child index counters) */
bool SetHDMasterKey(const CKey& key); bool SetHDMasterKey(const CKey& key);
const CHDChain& GetHDChain() { return hdChain; } const CHDChain& GetHDChain() { return hdChain; }
}; };

View file

@ -41,7 +41,7 @@ enum DBErrors
DB_NEED_REWRITE DB_NEED_REWRITE
}; };
/* simple hd chain data model */ /* simple HD chain data model */
class CHDChain class CHDChain
{ {
public: public:
@ -79,7 +79,7 @@ public:
int nVersion; int nVersion;
int64_t nCreateTime; // 0 means unknown int64_t nCreateTime; // 0 means unknown
std::string hdKeypath; //optional HD/bip32 keypath std::string hdKeypath; //optional HD/bip32 keypath
CKeyID hdMasterKeyID; //id of the hd masterkey used to derive this key CKeyID hdMasterKeyID; //id of the HD masterkey used to derive this key
CKeyMetadata() CKeyMetadata()
{ {