Merge pull request #6057
7e6569e
[squashme] improve/corrects prune mode detection test for required wallet rescans (Jonas Schnelli)7a12119
[RPC] disable import functions in pruned mode (Jonas Schnelli)3201035
[autoprune] allow wallet in pruned mode (Jonas Schnelli)
This commit is contained in:
commit
ac5476e2c1
2 changed files with 24 additions and 6 deletions
21
src/init.cpp
21
src/init.cpp
|
@ -714,16 +714,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
|
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
|
||||||
|
|
||||||
// if using block pruning, then disable txindex
|
// if using block pruning, then disable txindex
|
||||||
// also disable the wallet (for now, until SPV support is implemented in wallet)
|
|
||||||
if (GetArg("-prune", 0)) {
|
if (GetArg("-prune", 0)) {
|
||||||
if (GetBoolArg("-txindex", false))
|
if (GetBoolArg("-txindex", false))
|
||||||
return InitError(_("Prune mode is incompatible with -txindex."));
|
return InitError(_("Prune mode is incompatible with -txindex."));
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (!GetBoolArg("-disablewallet", false)) {
|
if (GetBoolArg("-rescan", false)) {
|
||||||
if (SoftSetBoolArg("-disablewallet", true))
|
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
|
||||||
LogPrintf("%s : parameter interaction: -prune -> setting -disablewallet=1\n", __func__);
|
|
||||||
else
|
|
||||||
return InitError(_("Can't run with a wallet in prune mode."));
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1310,6 +1306,19 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
}
|
}
|
||||||
if (chainActive.Tip() && chainActive.Tip() != pindexRescan)
|
if (chainActive.Tip() && chainActive.Tip() != pindexRescan)
|
||||||
{
|
{
|
||||||
|
//We can't rescan beyond non-pruned blocks, stop and throw an error
|
||||||
|
//this might happen if a user uses a old wallet within a pruned node
|
||||||
|
// or if he ran -disablewallet for a longer time, then decided to re-enable
|
||||||
|
if (fPruneMode)
|
||||||
|
{
|
||||||
|
CBlockIndex *block = chainActive.Tip();
|
||||||
|
while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA) && block->pprev->nTx > 0 && pindexRescan != block)
|
||||||
|
block = block->pprev;
|
||||||
|
|
||||||
|
if (pindexRescan != block)
|
||||||
|
return InitError(_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)"));
|
||||||
|
}
|
||||||
|
|
||||||
uiInterface.InitMessage(_("Rescanning..."));
|
uiInterface.InitMessage(_("Rescanning..."));
|
||||||
LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight);
|
LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight);
|
||||||
nStart = GetTimeMillis();
|
nStart = GetTimeMillis();
|
||||||
|
|
|
@ -94,6 +94,9 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||||
+ HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")
|
+ HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (fPruneMode)
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, "Importing keys is disabled in pruned mode");
|
||||||
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
EnsureWalletIsUnlocked();
|
EnsureWalletIsUnlocked();
|
||||||
|
@ -166,6 +169,9 @@ UniValue importaddress(const UniValue& params, bool fHelp)
|
||||||
+ HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false")
|
+ HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (fPruneMode)
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, "Importing addresses is disabled in pruned mode");
|
||||||
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
CScript script;
|
CScript script;
|
||||||
|
@ -236,6 +242,9 @@ UniValue importwallet(const UniValue& params, bool fHelp)
|
||||||
+ HelpExampleRpc("importwallet", "\"test\"")
|
+ HelpExampleRpc("importwallet", "\"test\"")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (fPruneMode)
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, "Importing wallets is disabled in pruned mode");
|
||||||
|
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
EnsureWalletIsUnlocked();
|
EnsureWalletIsUnlocked();
|
||||||
|
|
Loading…
Add table
Reference in a new issue