Merge branch 'duke' of https://github.com/MyHush/hush3 into duke
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -1,3 +1,4 @@
|
|||||||
jl777 https://github.com/jl777
|
jl777 https://github.com/jl777
|
||||||
Duke Leto https://github.com/leto
|
Duke Leto https://github.com/leto
|
||||||
|
DenioD https://github.com/DenioD
|
||||||
|
|
||||||
|
|||||||
@@ -323,19 +323,24 @@ UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"z_importwallet \"filename\"\n"
|
"z_importwallet \"filename\"\n"
|
||||||
"\nImports taddr and zaddr keys from a wallet export file (see z_exportwallet).\n"
|
"\nImports taddr and zaddr keys from a wallet export file (see z_exportwallet).\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"filename\" (string, required) The wallet file\n"
|
"1. \"filename\" (string, required) The wallet file\n"
|
||||||
|
"2. rescan (boolean, optional, default=yes) Rescan the wallet for transactions\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
"\nDump the wallet\n"
|
"\nDump the wallet\n"
|
||||||
+ HelpExampleCli("z_exportwallet", "\"nameofbackup\"") +
|
+ HelpExampleCli("z_exportwallet", "\"nameofbackup\"") +
|
||||||
"\nImport the wallet\n"
|
"\nImport the wallet\n"
|
||||||
+ HelpExampleCli("z_importwallet", "\"path/to/exportdir/nameofbackup\"") +
|
+ HelpExampleCli("z_importwallet", "\"path/to/exportdir/nameofbackup\"") +
|
||||||
"\nImport using the json rpc call\n"
|
"\nImport using the json rpc call\n"
|
||||||
+ HelpExampleRpc("z_importwallet", "\"path/to/exportdir/nameofbackup\"")
|
+ HelpExampleRpc("z_importwallet", "\"path/to/exportdir/nameofbackup\"")+
|
||||||
|
"\nImport the wallet without rescan\n"
|
||||||
|
+ HelpExampleCli("z_importwallet", "\"path/to/exportdir/nameofbackup\" no ")+
|
||||||
|
"\nImport without Rescan using the json rpc call\n"
|
||||||
|
+ HelpExampleRpc("z_importwallet", "\"path/to/exportdir/nameofbackup\" no")
|
||||||
);
|
);
|
||||||
|
|
||||||
return importwallet_impl(params, fHelp, true);
|
return importwallet_impl(params, fHelp, true);
|
||||||
@@ -346,19 +351,24 @@ UniValue importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
|||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
return NullUniValue;
|
return NullUniValue;
|
||||||
|
|
||||||
if (fHelp || params.size() != 1)
|
if (fHelp || params.size() < 1 || params.size() > 2)
|
||||||
throw runtime_error(
|
throw runtime_error(
|
||||||
"importwallet \"filename\"\n"
|
"importwallet \"filename\"\n"
|
||||||
"\nImports taddr keys from a wallet dump file (see dumpwallet).\n"
|
"\nImports taddr keys from a wallet dump file (see dumpwallet).\n"
|
||||||
"\nArguments:\n"
|
"\nArguments:\n"
|
||||||
"1. \"filename\" (string, required) The wallet file\n"
|
"1. \"filename\" (string, required) The wallet file\n"
|
||||||
|
"2. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
"\nDump the wallet\n"
|
"\nDump the wallet\n"
|
||||||
+ HelpExampleCli("dumpwallet", "\"nameofbackup\"") +
|
+ HelpExampleCli("dumpwallet", "\"nameofbackup\"") +
|
||||||
"\nImport the wallet\n"
|
"\nImport the wallet\n"
|
||||||
+ HelpExampleCli("importwallet", "\"path/to/exportdir/nameofbackup\"") +
|
+ HelpExampleCli("importwallet", "\"path/to/exportdir/nameofbackup\"") +
|
||||||
"\nImport using the json rpc call\n"
|
"\nImport using the json rpc call\n"
|
||||||
+ HelpExampleRpc("importwallet", "\"path/to/exportdir/nameofbackup\"")
|
+ HelpExampleRpc("importwallet", "\"path/to/exportdir/nameofbackup\"")+
|
||||||
|
"\nImport the wallet without rescan\n"
|
||||||
|
+ HelpExampleCli("importwallet", "\"path/to/exportdir/nameofbackup\" no ")+
|
||||||
|
"\nImport without Rescan using the json rpc call\n"
|
||||||
|
+ HelpExampleRpc("importwallet", "\"path/to/exportdir/nameofbackup\" no ")
|
||||||
);
|
);
|
||||||
|
|
||||||
return importwallet_impl(params, fHelp, false);
|
return importwallet_impl(params, fHelp, false);
|
||||||
@@ -456,23 +466,47 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys
|
|||||||
file.close();
|
file.close();
|
||||||
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
|
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
|
||||||
|
|
||||||
CBlockIndex *pindex = chainActive.LastTip();
|
bool fRescan = true;
|
||||||
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
if (params.size() > 1){
|
||||||
pindex = pindex->pprev;
|
auto rescan = params[1].get_str();
|
||||||
|
if (rescan.compare("yes") == 0) {
|
||||||
|
fRescan = true;
|
||||||
|
} else if (rescan.compare("no") == 0) {
|
||||||
|
fRescan = false;
|
||||||
|
} else { // Handle older API
|
||||||
|
UniValue jVal;
|
||||||
|
if (!jVal.read(std::string("[")+rescan+std::string("]")) ||
|
||||||
|
!jVal.isArray() || jVal.size()!=1 || !jVal[0].isBool()) {
|
||||||
|
throw JSONRPCError(
|
||||||
|
RPC_INVALID_PARAMETER,
|
||||||
|
"rescan must be \"yes\", \"no\"");
|
||||||
|
}
|
||||||
|
fRescan = jVal[0].getBool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
|
if (fRescan) {
|
||||||
pwalletMain->nTimeFirstKey = nTimeBegin;
|
CBlockIndex *pindex = chainActive.LastTip();
|
||||||
|
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
|
||||||
|
pindex = pindex->pprev;
|
||||||
|
|
||||||
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->GetHeight() + 1);
|
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->GetHeight() + 1);
|
||||||
pwalletMain->ScanForWalletTransactions(pindex);
|
if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
|
||||||
pwalletMain->MarkDirty();
|
pwalletMain->nTimeFirstKey = nTimeBegin;
|
||||||
|
pwalletMain->ScanForWalletTransactions(pindex);
|
||||||
|
pwalletMain->MarkDirty();
|
||||||
|
|
||||||
if (!fGood)
|
if (!fGood)
|
||||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
|
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
|
||||||
|
|
||||||
return NullUniValue;
|
return NullUniValue; }
|
||||||
|
|
||||||
|
else{
|
||||||
|
LogPrintf("Importwallet without Rescan successfull\n");
|
||||||
|
return NullUniValue;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UniValue dumpprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue dumpprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(fHelp))
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
|||||||
Reference in New Issue
Block a user