Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | UniValue importprivkey(const Config &config, const JSONRPCRequest &request) { | ||||
if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Cannot import private keys to a wallet with " | "Cannot import private keys to a wallet with " | ||||
"private keys disabled"); | "private keys disabled"); | ||||
} | } | ||||
EnsureLegacyScriptPubKeyMan(*wallet); | EnsureLegacyScriptPubKeyMan(*wallet); | ||||
WalletRescanReserver reserver(pwallet); | WalletRescanReserver reserver(*pwallet); | ||||
bool fRescan = true; | bool fRescan = true; | ||||
{ | { | ||||
auto locked_chain = pwallet->chain().lock(); | auto locked_chain = pwallet->chain().lock(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
std::string strSecret = request.params[0].get_str(); | std::string strSecret = request.params[0].get_str(); | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | UniValue importaddress(const Config &config, const JSONRPCRequest &request) { | ||||
if (fRescan && pwallet->chain().havePruned()) { | if (fRescan && pwallet->chain().havePruned()) { | ||||
// Exit early and print an error. | // Exit early and print an error. | ||||
// If a block is pruned after this check, we will import the key(s), | // If a block is pruned after this check, we will import the key(s), | ||||
// but fail the rescan with a generic error. | // but fail the rescan with a generic error. | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Rescan is disabled when blocks are pruned"); | "Rescan is disabled when blocks are pruned"); | ||||
} | } | ||||
WalletRescanReserver reserver(pwallet); | WalletRescanReserver reserver(*pwallet); | ||||
if (fRescan && !reserver.reserve()) { | if (fRescan && !reserver.reserve()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_WALLET_ERROR, | RPC_WALLET_ERROR, | ||||
"Wallet is currently rescanning. Abort existing rescan or wait."); | "Wallet is currently rescanning. Abort existing rescan or wait."); | ||||
} | } | ||||
// Whether to import a p2sh version, too | // Whether to import a p2sh version, too | ||||
bool fP2SH = false; | bool fP2SH = false; | ||||
▲ Show 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | UniValue importpubkey(const Config &config, const JSONRPCRequest &request) { | ||||
if (fRescan && pwallet->chain().havePruned()) { | if (fRescan && pwallet->chain().havePruned()) { | ||||
// Exit early and print an error. | // Exit early and print an error. | ||||
// If a block is pruned after this check, we will import the key(s), | // If a block is pruned after this check, we will import the key(s), | ||||
// but fail the rescan with a generic error. | // but fail the rescan with a generic error. | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Rescan is disabled when blocks are pruned"); | "Rescan is disabled when blocks are pruned"); | ||||
} | } | ||||
WalletRescanReserver reserver(pwallet); | WalletRescanReserver reserver(*pwallet); | ||||
if (fRescan && !reserver.reserve()) { | if (fRescan && !reserver.reserve()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_WALLET_ERROR, | RPC_WALLET_ERROR, | ||||
"Wallet is currently rescanning. Abort existing rescan or wait."); | "Wallet is currently rescanning. Abort existing rescan or wait."); | ||||
} | } | ||||
if (!IsHex(request.params[0].get_str())) { | if (!IsHex(request.params[0].get_str())) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (pwallet->chain().havePruned()) { | ||||
// Exit early and print an error. | // Exit early and print an error. | ||||
// If a block is pruned after this check, we will import the key(s), | // If a block is pruned after this check, we will import the key(s), | ||||
// but fail the rescan with a generic error. | // but fail the rescan with a generic error. | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_WALLET_ERROR, | RPC_WALLET_ERROR, | ||||
"Importing wallets is disabled when blocks are pruned"); | "Importing wallets is disabled when blocks are pruned"); | ||||
} | } | ||||
WalletRescanReserver reserver(pwallet); | WalletRescanReserver reserver(*pwallet); | ||||
if (!reserver.reserve()) { | if (!reserver.reserve()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_WALLET_ERROR, | RPC_WALLET_ERROR, | ||||
"Wallet is currently rescanning. Abort existing rescan or wait."); | "Wallet is currently rescanning. Abort existing rescan or wait."); | ||||
} | } | ||||
int64_t nTimeBegin = 0; | int64_t nTimeBegin = 0; | ||||
bool fGood = true; | bool fGood = true; | ||||
▲ Show 20 Lines • Show All 1,030 Lines • ▼ Show 20 Lines | UniValue importmulti(const Config &config, const JSONRPCRequest &mainRequest) { | ||||
if (!mainRequest.params[1].isNull()) { | if (!mainRequest.params[1].isNull()) { | ||||
const UniValue &options = mainRequest.params[1]; | const UniValue &options = mainRequest.params[1]; | ||||
if (options.exists("rescan")) { | if (options.exists("rescan")) { | ||||
fRescan = options["rescan"].get_bool(); | fRescan = options["rescan"].get_bool(); | ||||
} | } | ||||
} | } | ||||
WalletRescanReserver reserver(pwallet); | WalletRescanReserver reserver(*pwallet); | ||||
if (fRescan && !reserver.reserve()) { | if (fRescan && !reserver.reserve()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_WALLET_ERROR, | RPC_WALLET_ERROR, | ||||
"Wallet is currently rescanning. Abort existing rescan or wait."); | "Wallet is currently rescanning. Abort existing rescan or wait."); | ||||
} | } | ||||
int64_t now = 0; | int64_t now = 0; | ||||
bool fRunScan = false; | bool fRunScan = false; | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |