mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
(Partial) Merge #20125: rpc, wallet: Expose database format in getwalletinfo
624bab00dd2cc8e2ebd77dc0a669bc8d507c3721 test: add coverage for getwalletinfo format field (Jon Atack) 5e737a009234cbd7cf53748d3d28a2da5221192f rpc, wallet: Expose database format in getwalletinfo (João Barbosa) Pull request description: Support for sqlite based wallets was added in #19077. This PR adds the `format` key in `getwalletinfo` response, that can be `bdb` or `sqlite`. ACKs for top commit: jonatack: Tested ACK 624bab00dd2cc8e2ebd77dc0a669bc8d507c3721 laanwj: Code review ACK 624bab00dd2cc8e2ebd77dc0a669bc8d507c3721. MarcoFalke: doesn't hurt ACK 624bab00dd2cc8e2ebd77dc0a669bc8d507c3721 hebasto: ACK 624bab00dd2cc8e2ebd77dc0a669bc8d507c3721, tested on Linux Mint 20 (x86_64). meshcollider: utACK 624bab00dd2cc8e2ebd77dc0a669bc8d507c3721 Tree-SHA512: a81f8530f040f6381d33e073a65f281993eccfa717424ab6e651c1203cbaf27794dcb7175570459e7fdaa211565bc060d0a3ecbe70d2b6f9c49b8d5071e4441c
This commit is contained in:
parent
1ec0e30afb
commit
a850f5ff6f
@ -143,6 +143,7 @@ public:
|
|||||||
/** Return path to main database filename */
|
/** Return path to main database filename */
|
||||||
std::string Filename() override { return (env->Directory() / strFile).string(); }
|
std::string Filename() override { return (env->Directory() / strFile).string(); }
|
||||||
|
|
||||||
|
std::string Format() override { return "bdb"; }
|
||||||
/**
|
/**
|
||||||
* Pointer to shared database environment.
|
* Pointer to shared database environment.
|
||||||
*
|
*
|
||||||
|
@ -143,6 +143,8 @@ public:
|
|||||||
/** Return path to main database file for logs and error messages. */
|
/** Return path to main database file for logs and error messages. */
|
||||||
virtual std::string Filename() = 0;
|
virtual std::string Filename() = 0;
|
||||||
|
|
||||||
|
virtual std::string Format() = 0;
|
||||||
|
|
||||||
std::atomic<unsigned int> nUpdateCounter;
|
std::atomic<unsigned int> nUpdateCounter;
|
||||||
unsigned int nLastSeen;
|
unsigned int nLastSeen;
|
||||||
unsigned int nLastFlushed;
|
unsigned int nLastFlushed;
|
||||||
@ -189,6 +191,7 @@ public:
|
|||||||
void IncrementUpdateCounter() override { ++nUpdateCounter; }
|
void IncrementUpdateCounter() override { ++nUpdateCounter; }
|
||||||
void ReloadDbEnv() override {}
|
void ReloadDbEnv() override {}
|
||||||
std::string Filename() override { return "dummy"; }
|
std::string Filename() override { return "dummy"; }
|
||||||
|
std::string Format() override { return "dummy"; }
|
||||||
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override { return std::make_unique<DummyBatch>(); }
|
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override { return std::make_unique<DummyBatch>(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2489,6 +2489,7 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
|
|||||||
{
|
{
|
||||||
{RPCResult::Type::STR, "walletname", "the wallet name"},
|
{RPCResult::Type::STR, "walletname", "the wallet name"},
|
||||||
{RPCResult::Type::NUM, "walletversion", "the wallet version"},
|
{RPCResult::Type::NUM, "walletversion", "the wallet version"},
|
||||||
|
{RPCResult::Type::STR, "format", "the database format (bdb or sqlite)"},
|
||||||
{RPCResult::Type::NUM, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"},
|
{RPCResult::Type::NUM, "balance", "DEPRECATED. Identical to getbalances().mine.trusted"},
|
||||||
{RPCResult::Type::NUM, "coinjoin_balance", "DEPRECATED. Identical to getbalances().mine.coinjoin"},
|
{RPCResult::Type::NUM, "coinjoin_balance", "DEPRECATED. Identical to getbalances().mine.coinjoin"},
|
||||||
{RPCResult::Type::NUM, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
|
{RPCResult::Type::NUM, "unconfirmed_balance", "DEPRECATED. Identical to getbalances().mine.untrusted_pending"},
|
||||||
@ -2545,6 +2546,7 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
|
|||||||
const auto bal = pwallet->GetBalance();
|
const auto bal = pwallet->GetBalance();
|
||||||
obj.pushKV("walletname", pwallet->GetName());
|
obj.pushKV("walletname", pwallet->GetName());
|
||||||
obj.pushKV("walletversion", pwallet->GetVersion());
|
obj.pushKV("walletversion", pwallet->GetVersion());
|
||||||
|
obj.pushKV("format", pwallet->GetDatabase().Format());
|
||||||
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
|
obj.pushKV("balance", ValueFromAmount(bal.m_mine_trusted));
|
||||||
obj.pushKV("coinjoin_balance", ValueFromAmount(bal.m_anonymized));
|
obj.pushKV("coinjoin_balance", ValueFromAmount(bal.m_anonymized));
|
||||||
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
|
obj.pushKV("unconfirmed_balance", ValueFromAmount(bal.m_mine_untrusted_pending));
|
||||||
|
@ -28,7 +28,7 @@ class WalletStorage
|
|||||||
public:
|
public:
|
||||||
virtual ~WalletStorage() = default;
|
virtual ~WalletStorage() = default;
|
||||||
virtual const std::string GetDisplayName() const = 0;
|
virtual const std::string GetDisplayName() const = 0;
|
||||||
virtual WalletDatabase& GetDatabase() = 0;
|
virtual WalletDatabase& GetDatabase() const = 0;
|
||||||
virtual bool IsWalletFlagSet(uint64_t) const = 0;
|
virtual bool IsWalletFlagSet(uint64_t) const = 0;
|
||||||
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
|
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
|
||||||
virtual bool CanSupportFeature(enum WalletFeature) const = 0;
|
virtual bool CanSupportFeature(enum WalletFeature) const = 0;
|
||||||
|
@ -105,6 +105,7 @@ public:
|
|||||||
void IncrementUpdateCounter() override { ++nUpdateCounter; }
|
void IncrementUpdateCounter() override { ++nUpdateCounter; }
|
||||||
|
|
||||||
std::string Filename() override { return m_file_path; }
|
std::string Filename() override { return m_file_path; }
|
||||||
|
std::string Format() override { return "sqlite"; }
|
||||||
|
|
||||||
/** Make a SQLiteBatch connected to this database */
|
/** Make a SQLiteBatch connected to this database */
|
||||||
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override;
|
std::unique_ptr<DatabaseBatch> MakeBatch(bool flush_on_close = true) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user