Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 1,879 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
.Check(request); | .Check(request); | ||||
// Make sure the results are valid at least up to the most recent block | // Make sure the results are valid at least up to the most recent block | ||||
// the user could have gotten from another RPC command prior to now | // the user could have gotten from another RPC command prior to now | ||||
pwallet->BlockUntilSyncedToCurrentChain(); | pwallet->BlockUntilSyncedToCurrentChain(); | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
// The way the 'height' is initialized is just a workaround for the gcc bug | // Height of the specified block or the common ancestor, if the block | ||||
// #47679 since version 4.6.0. Height of the specified block or the common | // provided was in a deactivated chain. | ||||
// ancestor, if the block provided was in a deactivated chain. | std::optional<int> height; | ||||
Optional<int> height = MakeOptional(false, int()); | |||||
// Height of the specified block, even if it's in a deactivated chain. | // Height of the specified block, even if it's in a deactivated chain. | ||||
Optional<int> altheight; | std::optional<int> altheight; | ||||
int target_confirms = 1; | int target_confirms = 1; | ||||
isminefilter filter = ISMINE_SPENDABLE; | isminefilter filter = ISMINE_SPENDABLE; | ||||
BlockHash blockId; | BlockHash blockId; | ||||
if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { | if (!request.params[0].isNull() && !request.params[0].get_str().empty()) { | ||||
blockId = BlockHash(ParseHashV(request.params[0], "blockhash")); | blockId = BlockHash(ParseHashV(request.params[0], "blockhash")); | ||||
height.emplace(); | height.emplace(); | ||||
altheight.emplace(); | altheight.emplace(); | ||||
▲ Show 20 Lines • Show All 2,193 Lines • ▼ Show 20 Lines | UniValue rescanblockchain(const Config &config, const JSONRPCRequest &request) { | ||||
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."); | ||||
} | } | ||||
int start_height = 0; | int start_height = 0; | ||||
Optional<int> stop_height; | std::optional<int> stop_height; | ||||
BlockHash start_block; | BlockHash start_block; | ||||
{ | { | ||||
LOCK(pwallet->cs_wallet); | LOCK(pwallet->cs_wallet); | ||||
int tip_height = pwallet->GetLastBlockHeight(); | int tip_height = pwallet->GetLastBlockHeight(); | ||||
if (!request.params[0].isNull()) { | if (!request.params[0].isNull()) { | ||||
start_height = request.params[0].get_int(); | start_height = request.params[0].get_int(); | ||||
if (start_height < 0 || start_height > tip_height) { | if (start_height < 0 || start_height > tip_height) { | ||||
▲ Show 20 Lines • Show All 946 Lines • Show Last 20 Lines |