aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2023-11-21 21:48:57 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-12-05 18:55:35 -0300
commit1ce45baed7dd2da3f1cb85c9c25110e5537451ae (patch)
treece27b30a2adc42d59ad26cb49e00f63ac6e22e65 /src/wallet
parent83c66444d0604f0a9ec3bc3f89d4f1a810b7cda0 (diff)
downloadbitcoin-1ce45baed7dd2da3f1cb85c9c25110e5537451ae.tar.xz
rpc: getwalletinfo, return wallet 'birthtime'
And add coverage for it
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/rpc/wallet.cpp4
-rw-r--r--src/wallet/wallet.h3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp
index 164ce9afed..c635093344 100644
--- a/src/wallet/rpc/wallet.cpp
+++ b/src/wallet/rpc/wallet.cpp
@@ -69,6 +69,7 @@ static RPCHelpMan getwalletinfo()
{RPCResult::Type::BOOL, "descriptors", "whether this wallet uses descriptors for scriptPubKey management"},
{RPCResult::Type::BOOL, "external_signer", "whether this wallet is configured to use an external signer such as a hardware wallet"},
{RPCResult::Type::BOOL, "blank", "Whether this wallet intentionally does not contain any keys, scripts, or descriptors"},
+ {RPCResult::Type::NUM_TIME, "birthtime", /*optional=*/true, "The start time for blocks scanning. It could be modified by (re)importing any descriptor with an earlier timestamp."},
RESULT_LAST_PROCESSED_BLOCK,
}},
},
@@ -132,6 +133,9 @@ static RPCHelpMan getwalletinfo()
obj.pushKV("descriptors", pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
obj.pushKV("external_signer", pwallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER));
obj.pushKV("blank", pwallet->IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET));
+ if (int64_t birthtime = pwallet->GetBirthTime(); birthtime != UNKNOWN_TIME) {
+ obj.pushKV("birthtime", birthtime);
+ }
AppendLastProcessedBlock(obj, *pwallet);
return obj;
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index a1bf3784c9..3fac98c898 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -884,6 +884,9 @@ public:
/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
bool CanGetAddresses(bool internal = false) const;
+ /* Returns the time of the first created key or, in case of an import, it could be the time of the first received transaction */
+ int64_t GetBirthTime() const { return m_birth_time; }
+
/**
* Blocks until the wallet state is up-to-date to /at least/ the current
* chain at the time this function is entered