Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet: Replace -zapwallettxes with zapwallettxes RPC #19653

Closed
wants to merge 2 commits into from

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Aug 3, 2020

-zapwallettxes is known to not work with multiwallet and is currently disabled if multiple wallets are being loaded.

This PR removes the -zapwallettxes startup option and replaces its functionality with a zapwallettxes RPC command. This RPC does almost the same thing that the startup command did in that it removes all of the transactions from the target wallet. A blockchain rescan can optionally be triggered, as well as a mempool rescan. The default is to rescan the blockchain but not the mempool.

However a large difference is that -zapwallettxes would prevent the mempool from being loaded (#10330) but the RPC does not clear the mempool. However this does mean that the usefulness of this is questionable as the unconfirmed transactions that are being removed from the wallet would still appear in the mempool. The original behavior can be replicated by doing zapwallettxes and restarting with -persistmempool=0.

Also tests are updated to use the new RPC.

Updates the test to use this RPC. The test will also use multiple
wallets instead of multiple nodes
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 4, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK (feel free to ignore style nit)

@@ -4113,6 +4113,119 @@ static UniValue upgradewallet(const JSONRPCRequest& request)
return error.original;
}

static UniValue zapwallettxes(const JSONRPCRequest& request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: Can use the new constructor: https://doxygen.bitcoincore.org/class_c_r_p_c_command.html#afa39f5bda9319f3b91c6b38bbc7c7434 , so that it doesn't have to be changed in the future again (c.f. #19386)

@instagibbs
Copy link
Member

@laanwj brings up a point on irc that I think is good enough to bring up here: Why not just make this a wallet tool function? Might save some OP text space not worrying about mempool at all for this.

@maflcko
Copy link
Member

maflcko commented Aug 5, 2020

If you forget to start with -persistmempool=0, then even the wallet tool can't save you

@achow101
Copy link
Member Author

achow101 commented Aug 6, 2020

From today's IRC meeting, it seemed like the consensus was to make this part of the wallet tool. This seemed fine at first, but I started looking into that a bit more deeply and I think if we want to retain all of the same behavior, it doesn't quite work. The issue is the option to keep transaction metadata. This works by keeping the removed txs in a temp variable and restoring the metadata for the txs found during the rescan. However moving this to the wallet tool means that we will lose this behavior as that metadata will be lost and the wallet tool cannot do the rescan.

Removes the startup option and replaces it with an error message telling
users to use the RPC instead.
@ryanofsky
Copy link
Contributor

However moving this to the wallet tool means that we will lose this behavior as that metadata will be lost and the wallet tool cannot do the rescan.

No need for metadata to be lost I think. Wallet tool could do the equivalent of current zap command line option but instead of stashing metadata in a temporary variable, stash it in temporary rows. So the offline part of zap would clear BESTBLOCK and rename TX rows to ZAPTX rows. Then the rescan would scavenge and clear the ZAPTX rows.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@achow101
Copy link
Member Author

Closing in favor of #19700

@achow101 achow101 closed this Aug 12, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants