add rescan rpc
This commit is contained in:
@@ -489,6 +489,7 @@ extern UniValue z_getoperationstatus(const UniValue& params, bool fHelp, const C
|
|||||||
extern UniValue z_getoperationresult(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
extern UniValue z_getoperationresult(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
extern UniValue z_listoperationids(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
extern UniValue z_listoperationids(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
extern UniValue opreturn_burn(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
extern UniValue opreturn_burn(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
|
extern UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp
|
||||||
extern UniValue z_validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcmisc.cpp
|
extern UniValue z_validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcmisc.cpp
|
||||||
extern UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp
|
extern UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp
|
||||||
extern UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp
|
extern UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp
|
||||||
|
|||||||
@@ -149,6 +149,43 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& my
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
|
{
|
||||||
|
//LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
|
if (fHelp || params.size() > 1)
|
||||||
|
throw runtime_error(
|
||||||
|
"rescan \"height\"\n"
|
||||||
|
"\nRescan all transactions from genesis or given block height.\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. \"height\" (integer, optional) The block height to rescan from\n"
|
||||||
|
"\nExamples:\n"
|
||||||
|
"\nRescan from block height 555\n"
|
||||||
|
+ HelpExampleCli("rescan", "\"555\"") +
|
||||||
|
"\nRescan from genesis block\n"
|
||||||
|
+ HelpExampleCli("rescan","")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Height to rescan from
|
||||||
|
int nRescanHeight = 0;
|
||||||
|
if (params.size() > 0)
|
||||||
|
nRescanHeight = params[0].get_int();
|
||||||
|
if (nRescanHeight < 0 || nRescanHeight > chainActive.Height()) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
|
||||||
|
}
|
||||||
|
|
||||||
|
LogPrintf("Rescanning from height=%d\n", nRescanHeight);
|
||||||
|
//pwalletMain->ScanForWalletTransactions(chainActive[nRescanHeight],true);
|
||||||
|
bool update = false;
|
||||||
|
pwalletMain->ScanForWalletTransactions(chainActive.Genesis(),update);
|
||||||
|
//TODO: can we return something more useful?
|
||||||
|
return NullUniValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
|||||||
@@ -8228,6 +8228,8 @@ extern UniValue z_exportviewingkey(const UniValue& params, bool fHelp, const CPu
|
|||||||
extern UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
|
extern UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk);
|
||||||
|
|
||||||
|
|
||||||
static const CRPCCommand commands[] =
|
static const CRPCCommand commands[] =
|
||||||
{ // category name actor (function) okSafeMode
|
{ // category name actor (function) okSafeMode
|
||||||
@@ -8266,6 +8268,7 @@ static const CRPCCommand commands[] =
|
|||||||
{ "wallet", "listunspent", &listunspent, false },
|
{ "wallet", "listunspent", &listunspent, false },
|
||||||
{ "wallet", "lockunspent", &lockunspent, true },
|
{ "wallet", "lockunspent", &lockunspent, true },
|
||||||
{ "wallet", "move", &movecmd, false },
|
{ "wallet", "move", &movecmd, false },
|
||||||
|
{ "wallet", "rescan", &rescan, false },
|
||||||
{ "wallet", "sendfrom", &sendfrom, false },
|
{ "wallet", "sendfrom", &sendfrom, false },
|
||||||
{ "wallet", "sendmany", &sendmany, false },
|
{ "wallet", "sendmany", &sendmany, false },
|
||||||
{ "wallet", "sendtoaddress", &sendtoaddress, false },
|
{ "wallet", "sendtoaddress", &sendtoaddress, false },
|
||||||
|
|||||||
Reference in New Issue
Block a user