-
Notifications
You must be signed in to change notification settings - Fork 37.7k
wallet: be able to specify a wallet name and passphrase to migratewallet #26595
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: be able to specify a wallet name and passphrase to migratewallet #26595
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, 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. |
486ad67
to
d0b8bc9
Compare
d0b8bc9
to
fd6cdea
Compare
fd6cdea
to
7c1d18a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
src/wallet/rpc/wallet.cpp
Outdated
} else { | ||
res = MigrateLegacyToDescriptor(wallet_name, context); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 433f9f8 "rpc: Allow users to specify wallet name for migratewallet"
These lines don't seem to have any test coverage. Also, if GetWallet
is unable to get the wallet, shouldn't an error be thrown at that point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines don't seem to have any test coverage.
Tests are added in a later commit.
Also, if
GetWallet
is unable to get the wallet, shouldn't an error be thrown at that point?
No, GetWallet
only looks for wallets that have been loaded. But it is necessary to be able to migrate wallets that are not currently loaded. MigrateLegacyToDescriptor
will try loading the wallet and result in an error if it does not actually exist.
513debb
to
424ee3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK
424ee3e
to
8d957e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 8d957e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 8d957e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach ACK, some comments:
-
Thinking that the
MigrateLegacyToDescriptor
overload isn’t really needed, we only call this function from a single place which always receives a wallet name/path.
Could instead decouple the “UnloadWalletForMigration” process into a separate function, and call it at the beginning of the migration process ifGetWallet(wallet_name)
returns a wallet. e.g. furszy@456780b
This would let us remove the addedResult
default constructor too. -
Would be good to add a test for a wallet migration by absolute path (the “notloaded” test provides the wallet dir name and relies on the wallet internals to detect it as a directory inside the wallets dir).
e.g.
# Test migration by absolute path
wallet_file_path = os.path.join(self.nodes[0].datadir, "regtest/wallets", "notloaded")
self.nodes[0].migratewallet(wallet_file_path)
# check migration..
8d957e3
to
9ec4b11
Compare
Done as suggested
Added |
Rebased for a silent merge conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3e521b2
reACK 3e521b2 |
3e521b2
to
a0a9038
Compare
a0a9038
to
9486509
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reACK 9486509
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 9486509
reviewed code, ran tests, tested on regtest with cli commands
Show Signature
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
ACK 9486509be65f09174a0cb50a337cac58a0c09de4
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmP2L3gACgkQ5+KYS2KJ
yToaJA/9GCc9Y84y5GfTPsmAUUYV/jFKr5Z9lDIATQca+Ou323CQ76CF00IQiyBB
ECtPlFJSPxaaKac4k5QmwT4BA4EgzcTKKVhjCVlorHyJQYk5yYBD5xOk2G0fPthS
VA3CkmikXrpb7YGcxiKVvDLrOQ3h16+S2CI6/DViChgJ32cGbJ+WjZsqIb0Mx6tR
C7AtMPMjmjzt+oAbuzIhGzCfjglygUngGSIZbIotjRwgQ75ANJEApLYbUNyddz4a
6Pv9+sArKgvkNPzeOMxUbwjR3esTEAR2k70JpnZlxsf3alu6Jp6a8l7XkxZDoh5/
xyT/jdyHCqCiD0ZFpEAc2q4chFZgXzoMr7dcXesSiHzf64F8TStlG7ZKJn0EAPhG
Esal14rEIXh7OHVD5NHF1qOviGgzhrXBmkecbsX2jj0pUpcXg/cqH9Ln0bzYc//b
WBrc8pe1QPijzOlSXiEsHff3eDB8PWgK6uIgLld0y5bOgQ7YD6iex+exROzNcXK6
i5s8hJ8BNR0/sPWUt5zRA+BJ/pdQiHaJ3e1H2/X+UOkQuCKkLsyh1cLf0BI6Y9uJ
tUzgd3XDjh9wAUDPzf16o0mbOHzClK/6ak+wv6+WlubdCQXFMgOJdS3LWdDWgIE0
vwJluifh8hWN+vraJcM2ctDGL4KtdAndJ/UyznTXLBuBhhkmNXI=
=iPeZ
-----END PGP SIGNATURE-----
pinheadmz's public key is on keybase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 9486509
…sphrase to migratewallet 9486509 wallet, rpc: Update migratewallet help text for encrypted wallets (Andrew Chow) aaf02b5 tests: Tests for migrating wallets by name, and providing passphrase (Andrew Chow) 7fd125b wallet: Be able to unlock the wallet for migration (Andrew Chow) 6bdbc5f rpc: Allow users to specify wallet name for migratewallet (Andrew Chow) dbfa345 wallet: Allow MigrateLegacyToDescriptor to take a wallet name (Andrew Chow) Pull request description: `migratewallet` currently operates on wallets that are already loaded, however this is not necessarily required, and in the future, not possible once the legacy wallet is removed. So we need to also be able to give the wallet name to migrate. Additionally, the passphrase is required when migrating a wallet. Since a wallet may not be loaded when we migrate, and as we currently unload wallets when migrating, we need the passphrase to be given to `migratewallet` in order to migrate encrypted wallets. Fixes bitcoin#27048 ACKs for top commit: john-moffett: reACK 9486509 pinheadmz: ACK 9486509 furszy: ACK 9486509 Tree-SHA512: 35e2ba69a148e129a41e20d7fb99c4cab7947b1b7e7c362f4fd06ff8ac6e79e476e07207e063ba5b80e1a33e2343f4b4f1d72d7930ce80c34571c130d2f5cff4
An overload of MigrateLegacyToDescriptor is added which takes the wallet name. The original that took a wallet pointer is still available, it just gets the name, closes the wallet, and calls the new overload. Github-Pull: bitcoin#26595 Reabsed-From: dbfa345
Github-Pull: bitcoin#26595 Rebased-From: 6bdbc5f
Since migration reloads the wallet, the wallet will always be locked unless the passphrase is given. migratewallet can now take the passphrase in order to unlock the wallet for migration. Github-Pull: bitcoin#26595 Rebased-From: 7fd125b
Github-Pull: bitcoin#26595 Rebased-From: aaf02b5
Github-Pull: bitcoin#26595 Rebased-From: 9486509
Added to #26878 for backporting to 24.x. |
784a754 wallet, rpc: Update migratewallet help text for encrypted wallets (Andrew Chow) debcfe3 tests: Tests for migrating wallets by name, and providing passphrase (Andrew Chow) ccc72fe wallet: Be able to unlock the wallet for migration (Andrew Chow) 50dd8b1 rpc: Allow users to specify wallet name for migratewallet (Andrew Chow) 648b062 wallet: Allow MigrateLegacyToDescriptor to take a wallet name (Andrew Chow) ab3bd45 i2p: use consistent number of tunnels with i2pd and Java I2P (Vasil Dimov) 29cdf42 i2p: lower the number of tunnels for transient sessions (Vasil Dimov) 5027e93 i2p: reuse created I2P sessions if not used (Vasil Dimov) a62c541 wallet: reuse change dest when recreating TX with avoidpartialspends (Matthew Zipkin) 64e7db6 Zero out wallet master key upon lock (John Moffett) b7e242e Correctly limit overview transaction list (John Moffett) cff6718 depends: fix systemtap download URL (fanquake) 7cf73df Add missing includes to fix gcc-13 compile error (MarcoFalke) 07397cd addrdb: Only call Serialize() once (Martin Zumsande) 91f83db hash: add HashedSourceWriter (Martin Zumsande) 5c824ac For feebump, ignore abandoned descendant spends (John Moffett) 428dcd5 wallet: Skip rescanning if wallet is more recent than tip (Andrew Chow) cbcdafa test: wallet: check that labels are migrated to watchonly wallet (Sebastian Falbesoner) 342abfb wallet: fully migrate address book entries for watchonly/solvable wallets (Sebastian Falbesoner) Pull request description: Backports: * #26595 * #26675 * #26679 * #26761 * #26837 * #26909 * #26924 * #26944 * bitcoin-core/gui#704 * #27053 * #27080 ACKs for top commit: instagibbs: ACK 784a754 achow101: ACK 784a754 hebasto: ACK 784a754, I've made backporting locally and got a diff between my branch and this PR as follows: Tree-SHA512: 8ea84aa02d7907ff1e202e1302b441ce9ed2198bf383620ad40056a5d7e8ea88e1047abef0b92d85648016bf9b3195c974be3806ccebd85bef4f85c326869e43
migratewallet
currently operates on wallets that are already loaded, however this is not necessarily required, and in the future, not possible once the legacy wallet is removed. So we need to also be able to give the wallet name to migrate.Additionally, the passphrase is required when migrating a wallet. Since a wallet may not be loaded when we migrate, and as we currently unload wallets when migrating, we need the passphrase to be given to
migratewallet
in order to migrate encrypted wallets.Fixes #27048