diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -158,6 +158,7 @@ return (env->Directory() / strFile).string(); } + std::string Format() override { return "bdb"; } /** * Pointer to shared database environment. * diff --git a/src/wallet/db.h b/src/wallet/db.h --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -154,6 +154,8 @@ /** Return path to main database file for logs and error messages. */ virtual std::string Filename() = 0; + virtual std::string Format() = 0; + std::atomic nUpdateCounter; unsigned int nLastSeen; unsigned int nLastFlushed; @@ -209,6 +211,7 @@ void IncrementUpdateCounter() override { ++nUpdateCounter; } void ReloadDbEnv() override {} std::string Filename() override { return "dummy"; } + std::string Format() override { return "dummy"; } std::unique_ptr MakeBatch(bool flush_on_close = true) override { return std::make_unique(); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3013,6 +3013,8 @@ {RPCResult::Type::NUM, "walletversion", "the wallet version"}, {RPCResult::Type::STR_AMOUNT, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"}, + {RPCResult::Type::STR, "format", + "the database format (bdb or sqlite)"}, {RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to " "getbalances().mine.untrusted_pending"}, @@ -3088,6 +3090,7 @@ int64_t kp_oldest = pwallet->GetOldestKeyPoolTime(); obj.pushKV("walletname", pwallet->GetName()); obj.pushKV("walletversion", pwallet->GetVersion()); + obj.pushKV("format", pwallet->GetDatabase().Format()); obj.pushKV("balance", bal.m_mine_trusted); obj.pushKV("unconfirmed_balance", bal.m_mine_untrusted_pending); obj.pushKV("immature_balance", bal.m_mine_immature); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -35,7 +35,7 @@ public: virtual ~WalletStorage() = default; virtual const std::string GetDisplayName() const = 0; - virtual WalletDatabase &GetDatabase() = 0; + virtual WalletDatabase &GetDatabase() const = 0; virtual const CChainParams &GetChainParams() const = 0; virtual bool IsWalletFlagSet(uint64_t) const = 0; virtual void UnsetBlankWalletFlag(WalletBatch &) = 0; diff --git a/src/wallet/sqlite.h b/src/wallet/sqlite.h --- a/src/wallet/sqlite.h +++ b/src/wallet/sqlite.h @@ -106,6 +106,7 @@ void IncrementUpdateCounter() override { ++nUpdateCounter; } std::string Filename() override { return m_file_path; } + std::string Format() override { return "sqlite"; } /** Make a SQLiteBatch connected to this database */ std::unique_ptr diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -823,7 +823,7 @@ * be necessary. */ WalletDatabase &GetDBHandle() { return *database; } - WalletDatabase &GetDatabase() override { return *database; } + WalletDatabase &GetDatabase() const override { return *database; } /** * Select a set of coins such that nValueRet >= nTargetValue and at least diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -18,6 +18,9 @@ self.skip_if_no_wallet() def run_test(self): + wallet_info = self.nodes[0].getwalletinfo() + assert_equal(wallet_info['format'], 'bdb') + # Make a descriptor wallet self.log.info("Making a descriptor wallet") self.nodes[0].createwallet(wallet_name="desc1", descriptors=True) @@ -26,6 +29,7 @@ # A descriptor wallet should have 100 addresses = 100 keys self.log.info("Checking wallet info") wallet_info = self.nodes[0].getwalletinfo() + assert_equal(wallet_info['format'], 'bdb') assert_equal(wallet_info['keypoolsize'], 100) assert_equal(wallet_info['keypoolsize_hd_internal'], 100) assert 'keypoololdest' not in wallet_info