Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use internal HD chain for change outputs (hd split) #9294

Merged
merged 23 commits into from Mar 29, 2017
Merged
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
02592f4
[Wallet] split the keypool in an internal and external part
jonasschnelli Jan 10, 2017
d59531d
Immediately return setKeyPool's size if HD or HD_SPLIT is disabled or…
jonasschnelli Jan 16, 2017
01de822
Removed redundant IsLocked() check in NewKeyPool()
jonasschnelli Jan 16, 2017
05a9b49
Fix wrong keypool internal size in RPC getwalletinfo help
jonasschnelli Jan 16, 2017
469a47b
Make sure ReserveKeyFromKeyPool only hands out internal keys if HD_SP…
jonasschnelli Jan 16, 2017
9af8f00
Make sure we hand out keypool keys if HD_SPLIT is not enabled
jonasschnelli Jan 16, 2017
d0a627a
Fix issue where CDataStream->nVersion was taken a CKeyPool record ver…
jonasschnelli Jan 16, 2017
bcafca1
Make sure we always generate one keypool key at minimum
jonasschnelli Jan 16, 2017
79df9df
Switch to 100% for the HD internal keypool size
jonasschnelli Jan 17, 2017
dd526c2
Don't switch to HD-chain-split during wallet encryption of non HD-cha…
jonasschnelli Jan 17, 2017
add38d9
GetOldestKeyPoolTime: if HD & HD Chain Split is enabled, response max…
jonasschnelli Jan 17, 2017
e138876
Only show keypoolsize_hd_internal if HD split is enabled
jonasschnelli Jan 17, 2017
58e1483
CKeyPool avoid "catch (...)" in SerializationOp
jonasschnelli Jan 17, 2017
1090502
Fix superfluous cast and code style nits in RPC wallet-hd.py test
jonasschnelli Jan 26, 2017
d9638e5
Overhaul the internal/external key derive switch
jonasschnelli Jan 26, 2017
003e197
Remove FEATURE_HD_SPLIT bump TODO
jonasschnelli Jan 26, 2017
1b3b5c6
Slightly modify fundrawtransaction.py test (change getnewaddress() in…
jonasschnelli Feb 1, 2017
771a304
Make sure we set the wallets min version to FEATURE_HD_SPLIT at the v…
jonasschnelli Mar 24, 2017
ed79e4f
Optimize GetOldestKeyPoolTime(), return as soon as we have both oldes…
jonasschnelli Mar 24, 2017
cd468d0
Define CWallet::DeriveNewChildKey() as private
jonasschnelli Mar 24, 2017
1df08d1
Add assertion for CanSupportFeature(FEATURE_HD_SPLIT)
jonasschnelli Mar 24, 2017
9382f04
Do not break backward compatibility during wallet encryption
jonasschnelli Mar 27, 2017
4115af7
Fix rebase issue where pwalletMain was used instead of pwallet
jonasschnelli Mar 28, 2017
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+241 −89
Diff settings

Always

Just for now

Copy path View file
@@ -221,7 +221,7 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request)

CReserveKey reservekey(pwallet);
CPubKey vchPubKey;
if (!reservekey.GetReservedKey(vchPubKey))
if (!reservekey.GetReservedKey(vchPubKey, true))
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");

reservekey.KeepKey();
@@ -1852,7 +1852,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
" \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n"
" 'send' category of transactions.\n"
" \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
" 'send' category of transactions.\n"
" 'send' category of transactions.\n"
" }\n"
" ,...\n"
" ],\n"
@@ -2418,16 +2418,17 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
"Returns an object containing various wallet state info.\n"
"\nResult:\n"
"{\n"
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
" \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\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"
" \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
" \"hdmasterkeyid\": \"<hash160>\" (string) the Hash160 of the HD master pubkey\n"
" \"walletversion\": xxxxx, (numeric) the wallet version\n"
" \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n"
" \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n"
" \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n"
" \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n"
" \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)\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"
" \"hdmasterkeyid\": \"<hash160>\" (string) the Hash160 of the HD master pubkey\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getwalletinfo", "")
@@ -2437,18 +2438,23 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);

UniValue obj(UniValue::VOBJ);

size_t kpExternalSize = pwalletMain->KeypoolCountExternalKeys();

This comment has been minimized.

Copy link
@TheBlueMatt

TheBlueMatt Mar 27, 2017

Contributor

Oops, should be pwallet, not pwalletMain now :).

obj.push_back(Pair("walletversion", pwallet->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance())));
obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwallet->GetUnconfirmedBalance())));
obj.push_back(Pair("immature_balance", ValueFromAmount(pwallet->GetImmatureBalance())));
obj.push_back(Pair("txcount", (int)pwallet->mapWallet.size()));
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize()));
obj.push_back(Pair("keypoolsize", (int64_t)kpExternalSize));
CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID;
if (!masterKeyID.IsNull() && pwallet->CanSupportFeature(FEATURE_HD_SPLIT)) {
obj.push_back(Pair("keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize)));
}
if (pwallet->IsCrypted()) {
obj.push_back(Pair("unlocked_until", pwallet->nRelockTime));
}
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID;
if (!masterKeyID.IsNull())
obj.push_back(Pair("hdmasterkeyid", masterKeyID.GetHex()));
return obj;
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.