Skip to content

Commit 5e737a0

Browse files
committed
rpc, wallet: Expose database format in getwalletinfo
1 parent c4a29d0 commit 5e737a0

File tree

6 files changed

+9
-2
lines changed

6 files changed

+9
-2
lines changed

src/wallet/bdb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class BerkeleyDatabase : public WalletDatabase
146146
/** Return path to main database filename */
147147
std::string Filename() override { return (env->Directory() / strFile).string(); }
148148

149+
std::string Format() override { return "bdb"; }
149150
/**
150151
* Pointer to shared database environment.
151152
*

src/wallet/db.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ class WalletDatabase
144144
/** Return path to main database file for logs and error messages. */
145145
virtual std::string Filename() = 0;
146146

147+
virtual std::string Format() = 0;
148+
147149
std::atomic<unsigned int> nUpdateCounter;
148150
unsigned int nLastSeen;
149151
unsigned int nLastFlushed;
@@ -190,6 +192,7 @@ class DummyDatabase : public WalletDatabase
190192
void IncrementUpdateCounter() override { ++nUpdateCounter; }
191193
void ReloadDbEnv() override {}
192194
std::string Filename() override { return "dummy"; }
195+
std::string Format() override { return "dummy"; }
193196
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override { return MakeUnique<DummyBatch>(); }
194197
};
195198

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,7 @@ static RPCHelpMan getwalletinfo()
24222422
{
24232423
{RPCResult::Type::STR, "walletname", "the wallet name"},
24242424
{RPCResult::Type::NUM, "walletversion", "the wallet version"},
2425+
{RPCResult::Type::STR, "format", "the database format (bdb or sqlite)"},
24252426
{RPCResult::Type::STR_AMOUNT, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"},
24262427
{RPCResult::Type::STR_AMOUNT, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
24272428
{RPCResult::Type::STR_AMOUNT, "immature_balance", "DEPRECATED. Identical to getbalances().mine.immature"},
@@ -2465,6 +2466,7 @@ static RPCHelpMan getwalletinfo()
24652466
int64_t kp_oldest = pwallet->GetOldestKeyPoolTime();
24662467
obj.pushKV("walletname", pwallet->GetName());
24672468
obj.pushKV("walletversion", pwallet->GetVersion());
2469+
obj.pushKV("format", pwallet->GetDatabase().Format());
24682470
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
24692471
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
24702472
obj.pushKV("immature_balance", ValueFromAmount(bal.m_mine_immature));

src/wallet/scriptpubkeyman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class WalletStorage
3333
public:
3434
virtual ~WalletStorage() = default;
3535
virtual const std::string GetDisplayName() const = 0;
36-
virtual WalletDatabase& GetDatabase() = 0;
36+
virtual WalletDatabase& GetDatabase() const = 0;
3737
virtual bool IsWalletFlagSet(uint64_t) const = 0;
3838
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
3939
virtual bool CanSupportFeature(enum WalletFeature) const = 0;

src/wallet/sqlite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class SQLiteDatabase : public WalletDatabase
105105
void IncrementUpdateCounter() override { ++nUpdateCounter; }
106106

107107
std::string Filename() override { return m_file_path; }
108+
std::string Format() override { return "sqlite"; }
108109

109110
/** Make a SQLiteBatch connected to this database */
110111
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override;

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
739739
{
740740
return *database;
741741
}
742-
WalletDatabase& GetDatabase() override { return *database; }
742+
WalletDatabase& GetDatabase() const override { return *database; }
743743

744744
/**
745745
* Select a set of coins such that nValueRet >= nTargetValue and at least

0 commit comments

Comments
 (0)