rpc, wallet, refactor: Remove non-descriptor errors
It is not possible to load a legacy/ non-descriptor wallet anymore so no need to check for WALLET_FLAG_DESCRIPTORS in RPC calls, even when passing -rpcwallet/ JSON `/wallet/<walletname>/` endpoint, that searches for the wallets loaded already in the context.
This commit is contained in:
1 parent
573bcd75d7
commit
ce90f0c99f
2 files changed
-18
No files matched your search
@@ -356,11 +356,6 @@ RPCHelpMan importdescriptors()
|
|||||||
// the user could have gotten from another RPC command prior to now
|
// the user could have gotten from another RPC command prior to now
|
||||||
wallet.BlockUntilSyncedToCurrentChain();
|
wallet.BlockUntilSyncedToCurrentChain();
|
||||||
|
|
||||||
// Make sure wallet is a descriptor wallet
|
|
||||||
if (!pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "importdescriptors is not available for non-descriptor wallets");
|
|
||||||
}
|
|
||||||
|
|
||||||
WalletRescanReserver reserver(*pwallet);
|
WalletRescanReserver reserver(*pwallet);
|
||||||
if (!reserver.reserve(/*with_passphrase=*/true)) {
|
if (!reserver.reserve(/*with_passphrase=*/true)) {
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
|
||||||
@@ -493,10 +488,6 @@ RPCHelpMan listdescriptors()
|
|||||||
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
||||||
if (!wallet) return UniValue::VNULL;
|
if (!wallet) return UniValue::VNULL;
|
||||||
|
|
||||||
if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "listdescriptors is not available for non-descriptor wallets");
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool priv = !request.params[0].isNull() && request.params[0].get_bool();
|
const bool priv = !request.params[0].isNull() && request.params[0].get_bool();
|
||||||
if (priv) {
|
if (priv) {
|
||||||
EnsureWalletIsUnlocked(*wallet);
|
EnsureWalletIsUnlocked(*wallet);
|
||||||
|
|||||||
@@ -763,10 +763,6 @@ RPCHelpMan gethdkeys()
|
|||||||
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
||||||
if (!wallet) return UniValue::VNULL;
|
if (!wallet) return UniValue::VNULL;
|
||||||
|
|
||||||
if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "gethdkeys is not available for non-descriptor wallets");
|
|
||||||
}
|
|
||||||
|
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
|
|
||||||
UniValue options{request.params[0].isNull() ? UniValue::VOBJ : request.params[0]};
|
UniValue options{request.params[0].isNull() ? UniValue::VOBJ : request.params[0]};
|
||||||
@@ -865,11 +861,6 @@ static RPCHelpMan createwalletdescriptor()
|
|||||||
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
|
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
|
||||||
if (!pwallet) return UniValue::VNULL;
|
if (!pwallet) return UniValue::VNULL;
|
||||||
|
|
||||||
// Make sure wallet is a descriptor wallet
|
|
||||||
if (!pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "createwalletdescriptor is not available for non-descriptor wallets");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<OutputType> output_type = ParseOutputType(request.params[0].get_str());
|
std::optional<OutputType> output_type = ParseOutputType(request.params[0].get_str());
|
||||||
if (!output_type) {
|
if (!output_type) {
|
||||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
|
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
|
||||||
|
|||||||
Reference in new issue
Block a user