aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2016-08-19 18:47:23 +0200
committerJonas Schnelli <dev@jonasschnelli.ch>2016-08-19 18:47:49 +0200
commit2468292a03539c5b46220db15078f81915006915 (patch)
tree185d63dc2d1e801cc9babdd1c3d55e5d42df9965 /src/wallet
parent56ac0469609ad41e0ce3f002e87bd3d006c5c953 (diff)
parent914154f0ccf2a18a273c7fdb3e80016732149303 (diff)
downloadbitcoin-2468292a03539c5b46220db15078f81915006915.tar.xz
Merge #8517: [Qt] show wallet HD state in statusbar
914154f [Qt] add HD enabled/disabled icon to the status bar (Jonas Schnelli)
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet.cpp15
-rw-r--r--src/wallet/wallet.h3
2 files changed, 13 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 55936c0bbf..e19c40dbd1 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -98,7 +98,7 @@ CPubKey CWallet::GenerateNewKey()
CKeyMetadata metadata(nCreationTime);
// use HD key derivation if HD was enabled during wallet creation
- if (!hdChain.masterKeyID.IsNull()) {
+ if (IsHDEnabled()) {
// for now we use a fixed keypath scheme of m/0'/0'/k
CKey key; //master key seed (256bit)
CExtKey masterKey; //hd master key
@@ -628,7 +628,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
Unlock(strWalletPassphrase);
// if we are using HD, replace the HD master key (seed) with a new one
- if (!hdChain.masterKeyID.IsNull()) {
+ if (IsHDEnabled()) {
CKey key;
CPubKey masterPubKey = GenerateNewHDMasterKey();
if (!SetHDMasterKey(masterPubKey))
@@ -1233,6 +1233,11 @@ bool CWallet::SetHDChain(const CHDChain& chain, bool memonly)
return true;
}
+bool CWallet::IsHDEnabled()
+{
+ return !hdChain.masterKeyID.IsNull();
+}
+
int64_t CWalletTx::GetTxTime() const
{
int64_t n = nTimeSmart;
@@ -3322,7 +3327,7 @@ bool CWallet::InitLoadWallet()
if (fFirstRun)
{
// Create new keyUser and set as default key
- if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && walletInstance->hdChain.masterKeyID.IsNull()) {
+ if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) {
// generate a new master key
CPubKey masterPubKey = walletInstance->GenerateNewHDMasterKey();
if (!walletInstance->SetHDMasterKey(masterPubKey))
@@ -3339,9 +3344,9 @@ bool CWallet::InitLoadWallet()
}
else if (mapArgs.count("-usehd")) {
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
- if (!walletInstance->hdChain.masterKeyID.IsNull() && !useHD)
+ if (walletInstance->IsHDEnabled() && !useHD)
return InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), walletFile));
- if (walletInstance->hdChain.masterKeyID.IsNull() && useHD)
+ if (!walletInstance->IsHDEnabled() && useHD)
return InitError(strprintf(_("Error loading %s: You can't enable HD on a already existing non-HD wallet"), walletFile));
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 952acd1535..30f092e9a8 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -902,6 +902,9 @@ public:
bool SetHDChain(const CHDChain& chain, bool memonly);
const CHDChain& GetHDChain() { return hdChain; }
+ /* Returns true if HD is enabled */
+ bool IsHDEnabled();
+
/* Generates a new HD master key (will not be activated) */
CPubKey GenerateNewHDMasterKey();