-
Notifications
You must be signed in to change notification settings - Fork 266
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
Migrate legacy wallets that are not loaded #824
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. |
bb24232
to
bc8a218
Compare
Concept ACK. |
If we're preemptively making UX changes just to avoid changing UX in the future, it seems like we shouldn't take shortcuts like this... :/ |
We already do this in the RPC too, for exactly the same reason. |
bc8a218
to
d45ac03
Compare
void migrateWallet(WalletModel* wallet_model, QWidget* parent = nullptr); | ||
|
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.
Apparently, this code has been dead since introducing in #738.
src/qt/bitcoingui.cpp
Outdated
// Menu items remove single &. Single & are shown when && is in | ||
// the string, but only the first occurrence. So replace only | ||
// the first & with &&. | ||
name.replace(name.indexOf(QChar('&')), 1, QString("&&")); |
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.
#828 can relevant to this code.
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.
Since #828 has been merged, please keep in mind this update...
// Menu items remove single &. Single & are shown when && is in | |
// the string, but only the first occurrence. So replace only | |
// the first & with &&. | |
name.replace(name.indexOf(QChar('&')), 1, QString("&&")); | |
// Single & are shown when && is in the string. So replace & with &&. | |
name.replace(QChar('&'), QString("&&")); |
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.
Fixed during rebase.
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.
Fixed during rebase.
It still needs to be fixed.
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.
Ah, missed one, fixed.
Tested d45ac03. The "Migrate Wallet" menu item is still disabled when no wallet is loaded. |
Please rebase. |
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.
tACK d45ac03
Created a couple of legacy wallets (encrypted and not) to begin with.
edit: running ./configure with: --with-bdb
.
Using bitcoind
(./src/bitcoind -regtest -deprecatedrpc=create_bdb
) and bitcoin-cli
(./src/bitcoin-cli -regtest createwallet legacyWallet false false "" false false
) or directly on the rpc-console
(createwallet legacyWalletEnc false false "passphrase" false false
) in bitcoin-qt
(./src/qt/bitcoin-qt -regtest -deprecatedrpc=create_bdb
).
{
"name": "legacyWalletEnc",
"warnings": [
"Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future."
]
}
{
"name": "legacyWallet",
"warnings": [
"Empty string given as passphrase, wallet will not be encrypted.",
"Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future."
]
}
- I think that should be solved by removing the migration action from
BitcoinGUI::setWalletActionsEnabled
(the migration action has the same behaviour as the restore action which is not there).
d45ac03
to
bcf47b9
Compare
Should be fixed now.
I think that's ok. |
Yeah, it was just an observation (mainly to compare when the menu is disabled), thanks! |
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.
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.
Few comments. Will continue reviewing.
connect(action, &QAction::triggered, [this, wallet_name] { | ||
auto activity = new MigrateWalletActivity(m_wallet_controller, this); | ||
connect(activity, &MigrateWalletActivity::migrated, this, &BitcoinGUI::setCurrentWallet); | ||
activity->migrate(wallet_name); |
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.
Compilation error: error: 'wallet_name' in capture list does not name a variable
.
It seems the lambda expression cannot capture the structured binding. A local reference of the variable fixes it.
Same happens on the m_open_wallet_menu
action lambda with the "path" variable.
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.
What compiler? I'm not seeing this error, and it seems neither did CI.
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.
What compiler? I'm not seeing this error, and it seems neither did CI.
clang 14.0.3 (clang-1403.0.22.14.1).
bcf47b9
to
df9c1ef
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.
Worked further on your 8d0b5c1 to eliminate the need for the extra 'Yes, encrypted' button in the migration dialog, which I found quite unfriendly. Could replace it directly for furszy/bitcoin-core@e8d147e. It detects the wallet encryption status automatically regardless of its loaded/unloaded state.
Other than this, code is looking good.
df9c1ef
to
be93d63
Compare
Instead of having the code for the wallet display name being copy and pasted, use a GUIUtil function to get that for us.
To prepare for migrating wallets that are not loaded, when migration occurs in the GUI, it should not rely on a WalletModel existing. Co-authored-by: furszy <[email protected]>
be93d63
to
fd087d4
Compare
Cherry picked. Also fixed test failure. |
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 fd087d4
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.
Almost ACK fd087d4.
src/qt/bitcoingui.cpp
Outdated
// Menu items remove single &. Single & are shown when && is in | ||
// the string, but only the first occurrence. So replace only | ||
// the first & with &&. | ||
name.replace(name.indexOf(QChar('&')), 1, QString("&&")); |
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.
Fixed during rebase.
It still needs to be fixed.
Once legacy wallets can no longer be loaded, we need to be able to migrate them without loading. Thus we should use a menu that lists the wallets in the wallet directory instead of an action which migrates the currently loaded wallet.
fd087d4
to
8f2522d
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 8f2522d.
cc @furszy |
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 8f2522d
}); | ||
} | ||
if (m_migrate_wallet_menu->isEmpty()) { | ||
QAction* action = m_migrate_wallet_menu->addAction(tr("No wallets available")); |
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.
nit: maybe a more descriptive text would be good?
something like No wallets that need to be migrated
for people who don't know about the migration and why/what it is.
seeing No wallets available while they have wallet(s) might seem wrong/confusing.
sry for commenting post-merge
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.
Currently the Migrate Wallet menu item can only be used to migrate the currently loaded wallet. This is not suitable for the future when legacy wallets can no longer be loaded at all, but should still be able to be migrated. This PR changes that menu item into a menu list like Open Wallet and lets users migrate any legacy wallet in their wallet directory regardless of the wallets loaded.
One issue I ran into was dealing with encrypted wallets. Ideally, we would detect whether a wallet is encrypted, and prompt the user for their passphrase at that time. However, that's actually difficult to do in the GUI since migration will unload the wallet if it was already loaded, and reload it without connecting it to any signals or interfaces. Only then can it detect whether a wallet is encrypted, but then there is no
WalletModel
or even aninterfaces::Wallet
that the GUI could use to unlock it via a callback.To deal with this, I've opted to just add a button to the migration dialog box that has the user enter their passphrase first, along with instructional text to use that button if their wallet was encrypted. If the user enters the wrong passphrase or clicked the other button that does not prompt for the passphrase, migration will fail with a message indicating that the passphrase was incorrect.