mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Merge #13658: [moveonly] Extract RescanWallet to handle a simple rescan
3fe836b78d504942e8850b607453886969f57e27 [moveonly] Extract RescanWallet to handle a simple rescan (Ben Woosley) Pull request description: Where the outcome does not depend on the result, apart from a simple success check. Tree-SHA512: e0d29c6fc0c7f99a730289e5a80deb586b2848aead56b5198a71ef01f65374812468dfd57be0b8b076eb9be4090d5101d28d979a1d5c3d2f1caeca77b303e90e
This commit is contained in:
parent
ea58f30a6f
commit
ab9b8d3944
@ -65,6 +65,18 @@ static std::string DecodeDumpString(const std::string &str) {
|
|||||||
return ret.str();
|
return ret.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const int64_t TIMESTAMP_MIN = 0;
|
||||||
|
|
||||||
|
static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver, int64_t time_begin = TIMESTAMP_MIN, bool update = true)
|
||||||
|
{
|
||||||
|
int64_t scanned_time = wallet.RescanFromTime(time_begin, reserver, update);
|
||||||
|
if (wallet.IsAbortingRescan()) {
|
||||||
|
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
|
||||||
|
} else if (scanned_time > time_begin) {
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan was unable to fully rescan the blockchain. Some transactions may be missing.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UniValue importprivkey(const JSONRPCRequest& request)
|
UniValue importprivkey(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||||
@ -146,13 +158,7 @@ UniValue importprivkey(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fRescan) {
|
if (fRescan) {
|
||||||
int64_t scanned_time = pwallet->RescanFromTime(TIMESTAMP_MIN, reserver, true /* update */);
|
RescanWallet(*pwallet, reserver);
|
||||||
if (pwallet->IsAbortingRescan()) {
|
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
|
|
||||||
}
|
|
||||||
if (scanned_time > TIMESTAMP_MIN) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan was unable to fully rescan the blockchain. Some transactions may be missing.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
}
|
}
|
||||||
@ -291,13 +297,7 @@ UniValue importaddress(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
if (fRescan)
|
if (fRescan)
|
||||||
{
|
{
|
||||||
int64_t scanned_time = pwallet->RescanFromTime(TIMESTAMP_MIN, reserver, true /* update */);
|
RescanWallet(*pwallet, reserver);
|
||||||
if (pwallet->IsAbortingRescan()) {
|
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
|
|
||||||
}
|
|
||||||
if (scanned_time > TIMESTAMP_MIN) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan was unable to fully rescan the blockchain. Some transactions may be missing.");
|
|
||||||
}
|
|
||||||
pwallet->ReacceptWalletTransactions();
|
pwallet->ReacceptWalletTransactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,13 +466,7 @@ UniValue importpubkey(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
if (fRescan)
|
if (fRescan)
|
||||||
{
|
{
|
||||||
int64_t scanned_time = pwallet->RescanFromTime(TIMESTAMP_MIN, reserver, true /* update */);
|
RescanWallet(*pwallet, reserver);
|
||||||
if (pwallet->IsAbortingRescan()) {
|
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
|
|
||||||
}
|
|
||||||
if (scanned_time > TIMESTAMP_MIN) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan was unable to fully rescan the blockchain. Some transactions may be missing.");
|
|
||||||
}
|
|
||||||
pwallet->ReacceptWalletTransactions();
|
pwallet->ReacceptWalletTransactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,13 +594,7 @@ UniValue importwallet(const JSONRPCRequest& request)
|
|||||||
pwallet->UpdateTimeFirstKey(nTimeBegin);
|
pwallet->UpdateTimeFirstKey(nTimeBegin);
|
||||||
}
|
}
|
||||||
uiInterface.ShowProgress("", 100, false); // hide progress dialog in GUI
|
uiInterface.ShowProgress("", 100, false); // hide progress dialog in GUI
|
||||||
int64_t scanned_time = pwallet->RescanFromTime(nTimeBegin, reserver, false /* update */);
|
RescanWallet(*pwallet, reserver, nTimeBegin, false /* update */);
|
||||||
if (pwallet->IsAbortingRescan()) {
|
|
||||||
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
|
|
||||||
}
|
|
||||||
if (scanned_time > nTimeBegin) {
|
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Rescan was unable to fully rescan the blockchain. Some transactions may be missing.");
|
|
||||||
}
|
|
||||||
pwallet->MarkDirty();
|
pwallet->MarkDirty();
|
||||||
|
|
||||||
if (!fGood)
|
if (!fGood)
|
||||||
|
@ -66,8 +66,6 @@ static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
|
|||||||
static const bool DEFAULT_WALLETBROADCAST = true;
|
static const bool DEFAULT_WALLETBROADCAST = true;
|
||||||
static const bool DEFAULT_DISABLE_WALLET = false;
|
static const bool DEFAULT_DISABLE_WALLET = false;
|
||||||
|
|
||||||
static const int64_t TIMESTAMP_MIN = 0;
|
|
||||||
|
|
||||||
//! if set, all keys will be derived by using BIP39/BIP44
|
//! if set, all keys will be derived by using BIP39/BIP44
|
||||||
static const bool DEFAULT_USE_HD_WALLET = false;
|
static const bool DEFAULT_USE_HD_WALLET = false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user