diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/rpc/coins.cpp | 3 | ||||
-rw-r--r-- | src/wallet/rpc/transactions.cpp | 2 | ||||
-rw-r--r-- | src/wallet/rpc/util.cpp | 10 | ||||
-rw-r--r-- | src/wallet/rpc/util.h | 10 | ||||
-rw-r--r-- | src/wallet/rpc/wallet.cpp | 3 |
5 files changed, 26 insertions, 2 deletions
diff --git a/src/wallet/rpc/coins.cpp b/src/wallet/rpc/coins.cpp index 4c386789f1..750ef69f6e 100644 --- a/src/wallet/rpc/coins.cpp +++ b/src/wallet/rpc/coins.cpp @@ -448,6 +448,7 @@ RPCHelpMan getbalances() {RPCResult::Type::STR_AMOUNT, "untrusted_pending", "untrusted pending balance (outputs created by others that are in the mempool)"}, {RPCResult::Type::STR_AMOUNT, "immature", "balance from immature coinbase outputs"}, }}, + RESULT_LAST_PROCESSED_BLOCK, } }, RPCExamples{ @@ -488,6 +489,8 @@ RPCHelpMan getbalances() balances_watchonly.pushKV("immature", ValueFromAmount(bal.m_watchonly_immature)); balances.pushKV("watchonly", balances_watchonly); } + + AppendLastProcessedBlock(balances, wallet); return balances; }, }; diff --git a/src/wallet/rpc/transactions.cpp b/src/wallet/rpc/transactions.cpp index eb4f4c87ae..c34391e6e8 100644 --- a/src/wallet/rpc/transactions.cpp +++ b/src/wallet/rpc/transactions.cpp @@ -731,6 +731,7 @@ RPCHelpMan gettransaction() { {RPCResult::Type::ELISION, "", "Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."}, }}, + RESULT_LAST_PROCESSED_BLOCK, }) }, RPCExamples{ @@ -791,6 +792,7 @@ RPCHelpMan gettransaction() entry.pushKV("decoded", decoded); } + AppendLastProcessedBlock(entry, *pwallet); return entry; }, }; diff --git a/src/wallet/rpc/util.cpp b/src/wallet/rpc/util.cpp index 4d82e0a41f..4ff44b84b0 100644 --- a/src/wallet/rpc/util.cpp +++ b/src/wallet/rpc/util.cpp @@ -177,4 +177,14 @@ void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& st throw JSONRPCError(code, error.original); } } + +void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) +{ + AssertLockHeld(wallet.cs_wallet); + UniValue lastprocessedblock{UniValue::VOBJ}; + lastprocessedblock.pushKV("hash", wallet.GetLastBlockHash().GetHex()); + lastprocessedblock.pushKV("height", wallet.GetLastBlockHeight()); + entry.pushKV("lastprocessedblock", lastprocessedblock); +} + } // namespace wallet diff --git a/src/wallet/rpc/util.h b/src/wallet/rpc/util.h index d5d6ac0dfa..2fdba04352 100644 --- a/src/wallet/rpc/util.h +++ b/src/wallet/rpc/util.h @@ -5,7 +5,9 @@ #ifndef BITCOIN_WALLET_RPC_UTIL_H #define BITCOIN_WALLET_RPC_UTIL_H +#include <rpc/util.h> #include <script/script.h> +#include <wallet/wallet.h> #include <any> #include <memory> @@ -17,13 +19,17 @@ class UniValue; struct bilingual_str; namespace wallet { -class CWallet; class LegacyScriptPubKeyMan; enum class DatabaseStatus; struct WalletContext; extern const std::string HELP_REQUIRING_PASSPHRASE; +static const RPCResult RESULT_LAST_PROCESSED_BLOCK { RPCResult::Type::OBJ, "lastprocessedblock", "hash and height of the block this information was generated on",{ + {RPCResult::Type::STR_HEX, "hash", "hash of the block this information was generated on"}, + {RPCResult::Type::NUM, "height", "height of the block this information was generated on"}} +}; + /** * Figures out what wallet, if any, to use for a JSONRPCRequest. * @@ -45,8 +51,8 @@ std::string LabelFromValue(const UniValue& value); void PushParentDescriptors(const CWallet& wallet, const CScript& script_pubkey, UniValue& entry); void HandleWalletError(const std::shared_ptr<CWallet> wallet, DatabaseStatus& status, bilingual_str& error); - int64_t ParseISO8601DateTime(const std::string& str); +void AppendLastProcessedBlock(UniValue& entry, const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); } // namespace wallet #endif // BITCOIN_WALLET_RPC_UTIL_H diff --git a/src/wallet/rpc/wallet.cpp b/src/wallet/rpc/wallet.cpp index 7e57740706..d728b2fb96 100644 --- a/src/wallet/rpc/wallet.cpp +++ b/src/wallet/rpc/wallet.cpp @@ -68,6 +68,7 @@ static RPCHelpMan getwalletinfo() }, /*skip_type_check=*/true}, {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"}, + RESULT_LAST_PROCESSED_BLOCK, }}, }, RPCExamples{ @@ -129,6 +130,8 @@ static RPCHelpMan getwalletinfo() } obj.pushKV("descriptors", pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)); obj.pushKV("external_signer", pwallet->IsWalletFlagSet(WALLET_FLAG_EXTERNAL_SIGNER)); + + AppendLastProcessedBlock(obj, *pwallet); return obj; }, }; |