From ec2792d1dc3404d749a43556eeb4b63780ee6d94 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Thu, 26 Aug 2021 15:11:17 +0200 Subject: refactor: use const `LegacyScriptPubKeyMan` references in dump{privkey,wallet} RPCs --- src/wallet/rpcwallet.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/wallet/rpcwallet.cpp') diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 86bfa10d88..babb61b03a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -150,6 +150,15 @@ LegacyScriptPubKeyMan& EnsureLegacyScriptPubKeyMan(CWallet& wallet, bool also_cr return *spk_man; } +const LegacyScriptPubKeyMan& EnsureConstLegacyScriptPubKeyMan(const CWallet& wallet) +{ + const LegacyScriptPubKeyMan* spk_man = wallet.GetLegacyScriptPubKeyMan(); + if (!spk_man) { + throw JSONRPCError(RPC_WALLET_ERROR, "This type of wallet does not support this command"); + } + return *spk_man; +} + static void WalletTxToJSON(const CWallet& wallet, const CWalletTx& wtx, UniValue& entry) { interfaces::Chain& chain = wallet.chain(); -- cgit v1.2.3