aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
diff options
context:
space:
mode:
authorSamuel Dobson <dobsonsa68@gmail.com>2021-11-22 16:09:55 +1300
committerSamuel Dobson <dobsonsa68@gmail.com>2021-11-22 17:08:26 +1300
commita42923ce21870e7285252b32c4e4cb300fae1e1e (patch)
tree6c2b07bc9569b96dd19610da94f1e4c50c9dd4bb /src/wallet/scriptpubkeyman.cpp
parent79e64a053dfa757618a404c1ae83d07f160ab7e5 (diff)
parentee03c782ba61993d9e95fa499546cd14cee35445 (diff)
downloadbitcoin-a42923ce21870e7285252b32c4e4cb300fae1e1e.tar.xz
Merge bitcoin/bitcoin#23348: rpc, wallet: Do not return "keypoololdest" for blank descriptor wallets
ee03c782ba61993d9e95fa499546cd14cee35445 wallet: Make GetOldestKeyPoolTime return nullopt for blank wallets (Hennadii Stepanov) 3e4f069d23cd2ea5de8fa3c4b1a761ab097ad56f wallet, refactor: Make GetOldestKeyPoolTime return type std::optional (Hennadii Stepanov) Pull request description: The "keypoololdest" field in the `getwalletinfo` RPC response should be used for legacy wallets only. Th current implementation (04437ee721e66a7b76bef5ec2f88dd1efcd03b84) assumes that `CWallet::GetOldestKeyPoolTime()` always return `0` for descriptor wallets. This assumption is wrong for _blank_ descriptor wallets, when `m_spk_managers` is empty. As a result: ``` $ src/bitcoin-cli -signet -rpcwallet=211024-d-DPK getwalletinfo { "walletname": "211024-d-DPK", "walletversion": 169900, "format": "sqlite", "balance": 0.00000000, "unconfirmed_balance": 0.00000000, "immature_balance": 0.00000000, "txcount": 0, "keypoololdest": 9223372036854775807, "keypoolsize": 0, "keypoolsize_hd_internal": 0, "paytxfee": 0.00000000, "private_keys_enabled": false, "avoid_reuse": false, "scanning": false, "descriptors": true } ``` This PR fixes this issue with direct checking of the `WALLET_FLAG_DESCRIPTORS` flag. ACKs for top commit: lsilva01: re-ACK ee03c78 stratospher: ACK ee03c78. meshcollider: Code review ACK ee03c782ba61993d9e95fa499546cd14cee35445 Tree-SHA512: 9852f9f8ed5c08c07507274d7714f039bbfda66da6df65cf98f67bf11a600167d0f7f872680c95775399477f4df9ba9fce80ec0cbe0adb7f2bb33c3bd65b15df
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r--src/wallet/scriptpubkeyman.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 9173c790d4..faeb6068db 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -528,7 +528,7 @@ static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, Walle
return keypool.nTime;
}
-int64_t LegacyScriptPubKeyMan::GetOldestKeyPoolTime() const
+std::optional<int64_t> LegacyScriptPubKeyMan::GetOldestKeyPoolTime() const
{
LOCK(cs_KeyStore);
@@ -1970,11 +1970,10 @@ bool DescriptorScriptPubKeyMan::HavePrivateKeys() const
return m_map_keys.size() > 0 || m_map_crypted_keys.size() > 0;
}
-int64_t DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const
+std::optional<int64_t> DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const
{
// This is only used for getwalletinfo output and isn't relevant to descriptor wallets.
- // The magic number 0 indicates that it shouldn't be displayed so that's what we return.
- return 0;
+ return std::nullopt;
}