diff options
-rw-r--r-- | src/interfaces/chain.cpp | 1 | ||||
-rw-r--r-- | src/interfaces/chain.h | 3 | ||||
-rw-r--r-- | src/wallet/rpcdump.cpp | 8 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index f888606879..bb2af5b8ba 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -228,6 +228,7 @@ public: { return ::mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); } + bool getPruneMode() override { return ::fPruneMode; } }; } // namespace diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index d0f74cb100..96e4f8cf0b 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -155,6 +155,9 @@ public: //! Pool min fee. virtual CFeeRate mempoolMinFee() = 0; + + //! Check if pruning is enabled. + virtual bool getPruneMode() = 0; }; //! Interface to let node manage chain clients (wallets, or maybe tools for diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index f38202a2b8..046a6567a5 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -157,7 +157,7 @@ UniValue importprivkey(const JSONRPCRequest& request) if (!request.params[2].isNull()) fRescan = request.params[2].get_bool(); - if (fRescan && fPruneMode) + if (fRescan && pwallet->chain().getPruneMode()) throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode"); if (fRescan && !reserver.reserve()) { @@ -313,7 +313,7 @@ UniValue importaddress(const JSONRPCRequest& request) if (!request.params[2].isNull()) fRescan = request.params[2].get_bool(); - if (fRescan && fPruneMode) + if (fRescan && pwallet->chain().getPruneMode()) throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode"); WalletRescanReserver reserver(pwallet); @@ -501,7 +501,7 @@ UniValue importpubkey(const JSONRPCRequest& request) if (!request.params[2].isNull()) fRescan = request.params[2].get_bool(); - if (fRescan && fPruneMode) + if (fRescan && pwallet->chain().getPruneMode()) throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode"); WalletRescanReserver reserver(pwallet); @@ -562,7 +562,7 @@ UniValue importwallet(const JSONRPCRequest& request) }, }.ToString()); - if (fPruneMode) + if (pwallet->chain().getPruneMode()) throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode"); WalletRescanReserver reserver(pwallet); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 75681e2007..a0718309b9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4334,7 +4334,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain, //We can't rescan beyond non-pruned blocks, stop and throw an error //this might happen if a user uses an old wallet within a pruned node // or if he ran -disablewallet for a longer time, then decided to re-enable - if (fPruneMode) + if (chain.getPruneMode()) { int block_height = *tip_height; while (block_height > 0 && locked_chain->haveBlockOnDisk(block_height - 1) && rescan_height != block_height) { |