importwallet
fails if any block is pruned. This PR makes it possible to importwallet
if all required blocks aren’t pruned. This is possible because the dump format includes key timestamps.
importwallet
fails if any block is pruned. This PR makes it possible to importwallet
if all required blocks aren’t pruned. This is possible because the dump format includes key timestamps.
651 }
652 }
653 file.close();
654+ if (pwallet->chain().havePruned()) {
655+ Optional<int> pruned_height = locked_chain->findPruned();
656+ if (pruned_height && nTimeBegin < locked_chain->getBlockTime(*pruned_height)) {
The block lookup should be using findFirstBlockWithTime (see RescanFromTime) and allow some slop, because miners could have wrong clocks and users could have wrong clocks, TIMESTAMP_WINDOW, (again see RescanFromTime). This is particularly important for birthdays because installing the software and instantly generating a key, handing it out, and getting paid is a perfectly sensible sequence of events.
Otherwise– Concept ACK on doing this!
feature_prunning.py
, not wallet_dump.py
, WDYT?
wallet_pruning
.
importmulti
.
Updated to include the same check in importmulti.
How does that change the error message? Also, the import will happen before the check in importmuli, whereas in importwallet it will happen after.
the import will happen before the check in importmuli, whereas in importwallet it will happen after.
Now also checking before importing on importmulti
.
1449@@ -1446,21 +1450,27 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
1450 LOCK(pwallet->cs_wallet);
1451 EnsureWalletIsUnlocked(pwallet);
1452
1453- // Verify all timestamps are present before importing any keys.
1454+ const int64_t minimumTimestamp = 1;
utACK 9066b21cc45fdd9749d6e2d461d125e64182c963
Good stuff
Thanks for the review. I’m going to test these changes and add a release note. I’m leaning towards a new test file like you suggested.
BTW is there’s a way to change the .blk maximum size?
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Concept ACK. Travis unhappy.
Suggest renaming the PR to “[rpc] enable wallet import on pruned nodes”
100@@ -101,6 +101,14 @@ static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver,
101 }
102 }
103
104+static void EnsureBlockDataFromTime(interfaces::Chain::Lock& locked_chain, int64_t timestamp)
105+{
106+ const Optional<int> height = locked_chain.findFirstBlockWithTimeAndHeight(timestamp - TIMESTAMP_WINDOW, 0, nullptr);
107+ if (height && !locked_chain.haveBlockOnDisk(*height)) {
625+ if (birth_time > 0) nTimeBegin = std::min(nTimeBegin, birth_time);
626 scripts.push_back(std::pair<CScript, int64_t>(script, birth_time));
627 }
628 }
629 file.close();
630+ if (pwallet->chain().havePruned()) {
EnsureBlockDataFromTime
100@@ -101,6 +101,14 @@ static void RescanWallet(CWallet& wallet, const WalletRescanReserver& reserver,
101 }
102 }
103
104+static void EnsureBlockDataFromTime(interfaces::Chain::Lock& locked_chain, int64_t timestamp)
105+{
106+ const Optional<int> height = locked_chain.findFirstBlockWithTimeAndHeight(timestamp - TIMESTAMP_WINDOW, 0, nullptr);
std::optional
in new code.