|
|
|
@ -2149,7 +2149,8 @@ static RPCHelpMan scantxoutset()
|
|
|
|
|
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
|
|
|
|
{
|
|
|
|
|
UniValue result(UniValue::VOBJ);
|
|
|
|
|
if (request.params[0].get_str() == "status") {
|
|
|
|
|
const auto action{self.Arg<std::string>("action")};
|
|
|
|
|
if (action == "status") {
|
|
|
|
|
CoinsViewScanReserver reserver;
|
|
|
|
|
if (reserver.reserve()) {
|
|
|
|
|
// no scan in progress
|
|
|
|
@ -2157,7 +2158,7 @@ static RPCHelpMan scantxoutset()
|
|
|
|
|
}
|
|
|
|
|
result.pushKV("progress", g_scan_progress.load());
|
|
|
|
|
return result;
|
|
|
|
|
} else if (request.params[0].get_str() == "abort") {
|
|
|
|
|
} else if (action == "abort") {
|
|
|
|
|
CoinsViewScanReserver reserver;
|
|
|
|
|
if (reserver.reserve()) {
|
|
|
|
|
// reserve was possible which means no scan was running
|
|
|
|
@ -2166,7 +2167,7 @@ static RPCHelpMan scantxoutset()
|
|
|
|
|
// set the abort flag
|
|
|
|
|
g_should_abort_scan = true;
|
|
|
|
|
return true;
|
|
|
|
|
} else if (request.params[0].get_str() == "start") {
|
|
|
|
|
} else if (action == "start") {
|
|
|
|
|
CoinsViewScanReserver reserver;
|
|
|
|
|
if (!reserver.reserve()) {
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Scan already in progress, use action \"abort\" or \"status\"");
|
|
|
|
@ -2235,7 +2236,7 @@ static RPCHelpMan scantxoutset()
|
|
|
|
|
result.pushKV("unspents", unspents);
|
|
|
|
|
result.pushKV("total_amount", ValueFromAmount(total_in));
|
|
|
|
|
} else {
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid action '%s'", request.params[0].get_str()));
|
|
|
|
|
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid action '%s'", action));
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|