mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-19 12:10:19 +01:00
Add EnsureLegacyScriptPubKeyMan and use in rpcwallet.cpp
This also fixes unused variable warnings in rpcdump.cpp
This commit is contained in:
@@ -87,15 +87,6 @@ static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver,
|
||||
}
|
||||
}
|
||||
|
||||
static LegacyScriptPubKeyMan& GetLegacyScriptPubKeyMan(CWallet& wallet)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
UniValue importprivkey(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
@@ -134,7 +125,7 @@ UniValue importprivkey(const JSONRPCRequest& request)
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot import private keys to a wallet with private keys disabled");
|
||||
}
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
|
||||
EnsureLegacyScriptPubKeyMan(*wallet);
|
||||
|
||||
WalletRescanReserver reserver(pwallet);
|
||||
bool fRescan = true;
|
||||
@@ -262,7 +253,7 @@ UniValue importaddress(const JSONRPCRequest& request)
|
||||
},
|
||||
}.Check(request);
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*pwallet);
|
||||
EnsureLegacyScriptPubKeyMan(*pwallet);
|
||||
|
||||
std::string strLabel;
|
||||
if (!request.params[1].isNull())
|
||||
@@ -465,7 +456,7 @@ UniValue importpubkey(const JSONRPCRequest& request)
|
||||
},
|
||||
}.Check(request);
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
|
||||
EnsureLegacyScriptPubKeyMan(*wallet);
|
||||
|
||||
std::string strLabel;
|
||||
if (!request.params[1].isNull())
|
||||
@@ -549,7 +540,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
||||
},
|
||||
}.Check(request);
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
|
||||
EnsureLegacyScriptPubKeyMan(*wallet);
|
||||
|
||||
if (pwallet->chain().havePruned()) {
|
||||
// Exit early and print an error.
|
||||
@@ -708,7 +699,7 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
|
||||
},
|
||||
}.Check(request);
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
|
||||
LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*wallet);
|
||||
|
||||
auto locked_chain = pwallet->chain().lock();
|
||||
LOCK(pwallet->cs_wallet);
|
||||
@@ -759,7 +750,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
|
||||
},
|
||||
}.Check(request);
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
|
||||
LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*wallet);
|
||||
|
||||
auto locked_chain = pwallet->chain().lock();
|
||||
LOCK(pwallet->cs_wallet);
|
||||
@@ -1346,7 +1337,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
|
||||
|
||||
RPCTypeCheck(mainRequest.params, {UniValue::VARR, UniValue::VOBJ});
|
||||
|
||||
LegacyScriptPubKeyMan& spk_man = GetLegacyScriptPubKeyMan(*wallet);
|
||||
EnsureLegacyScriptPubKeyMan(*wallet);
|
||||
|
||||
const UniValue& requests = mainRequest.params[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user