Add wallet migration flow #539

Manually merged
johnny9 merged 8 commits from pr/feature-parity-13-migration-flow into qt6 2026-05-14 18:27:43 +00:00 AGit
johnny9 commented 2026-03-19 13:30:49 +00:00 (Migrated from github.com)
02-wallet-selector 03-migration-prompt 04-migration-complete

Fixes #517
Fixes #696

<img width="1319" height="854" alt="02-wallet-selector" src="https://git.fish.foo/attachments/7261dae6-6d0d-4f60-bab7-8ab2118fafc0" /> <img width="1319" height="854" alt="03-migration-prompt" src="https://git.fish.foo/attachments/96a8fd3f-6342-4b14-bac8-60d6ad45a0ce" /> <img width="1319" height="854" alt="04-migration-complete" src="https://git.fish.foo/attachments/c001fa7b-8232-4d1f-8d39-773f1d38a36c" /> Fixes #517 Fixes #696
johnny9 commented 2026-04-03 16:10:08 +00:00 (Migrated from github.com)

Related to #517

Related to #517
MarnixCroes (Migrated from github.com) reviewed 2026-05-06 13:38:14 +00:00
MarnixCroes (Migrated from github.com) left a comment

f0fe7f758d9a4c32e8e2780a10d27770a9d90494

Maybe you're aware, but I don't see it mentioned, there should be a way to enter a passphrase if needed.

f0fe7f758d9a4c32e8e2780a10d27770a9d90494 Maybe you're aware, but I don't see it mentioned, there should be a way to enter a passphrase if needed.
MarnixCroes (Migrated from github.com) commented 2026-05-06 13:29:31 +00:00

Having both cancel and back is unnecesary

Having both `cancel` and `back` is unnecesary
MarnixCroes (Migrated from github.com) commented 2026-05-06 13:30:30 +00:00

nit, maybe Wallet successfully migrated is better?

nit, maybe `Wallet successfully migrated` is better?
MarnixCroes (Migrated from github.com) commented 2026-05-06 13:28:15 +00:00
                    return qsTr("Done")

makes more sense

```suggestion return qsTr("Done") ``` makes more sense
johnny9 commented 2026-05-06 16:08:18 +00:00 (Migrated from github.com)

f0fe7f758d9a4c32e8e2780a10d27770a9d90494

Maybe you're aware, but I don't see it mentioned, there should be a way to enter a passphrase if needed.

548 adds the password dialog. So I guess depending on which gets merged first I'll add the dialog for migration instead of a blank password.

> f0fe7f758d9a4c32e8e2780a10d27770a9d90494 > > Maybe you're aware, but I don't see it mentioned, there should be a way to enter a passphrase if needed. 548 adds the password dialog. So I guess depending on which gets merged first I'll add the dialog for migration instead of a blank password.
MarnixCroes (Migrated from github.com) approved these changes 2026-05-08 12:34:47 +00:00
MarnixCroes (Migrated from github.com) left a comment

ACK 96b06c31429c35a66292908922ba381ae69e5680

ACK 96b06c31429c35a66292908922ba381ae69e5680
johnny9 commented 2026-05-08 15:28:38 +00:00 (Migrated from github.com)

from 96b06c3 to 1a86cdf

  • trivial rebase
from [96b06c3](https://github.com/bitcoin-core/gui-qml/commit/96b06c31429c35a66292908922ba381ae69e5680) to [1a86cdf](https://github.com/bitcoin-core/gui-qml/commit/1a86cdf11714ace60a809882484498c7e7135641) - trivial rebase
johnny9 commented 2026-05-11 15:51:03 +00:00 (Migrated from github.com)

another trivial rebase

another trivial rebase
johnny9 commented 2026-05-11 17:20:21 +00:00 (Migrated from github.com)

from 3ecc865 to 5055da4

  • fix the duplicate test property objectName: "walletSelectList" that was also added in recently merged PR
  • added checkpoint/screenshots to the qml test
from [3ecc865](https://github.com/bitcoin-core/gui-qml/commit/3ecc86572ff77d89bd92de7ffd8ee7ad88ddbc24) to [5055da4](https://github.com/bitcoin-core/gui-qml/commit/5055da406e3f1c9498a07f93f3c24e78f9f8e03f) - fix the duplicate test property `objectName: "walletSelectList"` that was also added in recently merged PR - added checkpoint/screenshots to the qml test
johnny9 commented 2026-05-14 02:43:34 +00:00 (Migrated from github.com)

Isolated QSettings configs in the qml functional tests as the recent Settings PR that changes languages leaked into other tests which resulted in expectations of labels not matching anymore

Isolated QSettings configs in the qml functional tests as the recent Settings PR that changes languages leaked into other tests which resulted in expectations of labels not matching anymore
jarolrod (Migrated from github.com) reviewed 2026-05-14 03:50:12 +00:00
jarolrod (Migrated from github.com) left a comment

ACK 596fc76df4

As a gui wallet flow, for unencrypted legacy wallets

But the detection of legacy should be reworked, we currently do brittle string error matching to detect if migration is needed. We shouldn't be doing this and instead we should be using m_node.walletLoader().listWalletDir() and querying it's info return to see if the wallet is BDB, then expose this to qml.

As the wallet controller is not being updated in this PR, this can be done in a separate PR.

For example, the following patch should convey the idea (patch doesn't touch your string matching code)

diff --git a/qml/models/walletlistmodel.cpp b/qml/models/walletlistmodel.cpp
index def378b7d..ead1e793b 100644
--- a/qml/models/walletlistmodel.cpp
+++ b/qml/models/walletlistmodel.cpp
@@ -6,8 +6,6 @@
 
 #include <interfaces/node.h>
 
-#include <QSet>
-
 WalletListModel::WalletListModel(interfaces::Node& node, QObject *parent)
 : QAbstractListModel(parent)
 , m_node(node)
@@ -16,17 +14,25 @@ WalletListModel::WalletListModel(interfaces::Node& node, QObject *parent)
 
 void WalletListModel::listWalletDir()
 {
-    QSet<QString> existing_names;
-    for (int i = 0; i < rowCount(); ++i) {
-        QModelIndex index = this->index(i, 0);
-        QString name = data(index, NameRole).toString();
-        existing_names.insert(name);
-    }
-
-    for (const auto& [path, info] : m_node.walletLoader().listWalletDir()) {
+    for (const auto& [path, format] : m_node.walletLoader().listWalletDir()) {
         QString qname = QString::fromStdString(path);
-        if (!existing_names.contains(qname)) {
-            addItem({ qname });
+        QString qformat = QString::fromStdString(format);
+        bool found = false;
+        for (int i = 0; i < rowCount(); ++i) {
+            if (m_items[i].name != qname) {
+                continue;
+            }
+            found = true;
+            if (m_items[i].format != qformat) {
+                m_items[i].format = qformat;
+                const QModelIndex changed_index = index(i, 0);
+                Q_EMIT dataChanged(changed_index, changed_index, {FormatRole, NeedsMigrationRole});
+            }
+            break;
+        }
+
+        if (!found) {
+            addItem({ qname, qformat });
         }
     }
 }
@@ -47,6 +53,10 @@ QVariant WalletListModel::data(const QModelIndex &index, int role) const
     case Qt::DisplayRole:
     case NameRole:
         return item.name;
+    case FormatRole:
+        return item.format;
+    case NeedsMigrationRole:
+        return item.format == QStringLiteral("bdb");
     default:
         return QVariant();
     }
@@ -56,6 +66,8 @@ QHash<int, QByteArray> WalletListModel::roleNames() const
 {
     QHash<int, QByteArray> roles;
     roles[NameRole] = "name";
+    roles[FormatRole] = "format";
+    roles[NeedsMigrationRole] = "needsMigration";
     return roles;
 }
 
diff --git a/qml/models/walletlistmodel.h b/qml/models/walletlistmodel.h
index c36cb2b4f..13ae99037 100644
--- a/qml/models/walletlistmodel.h
+++ b/qml/models/walletlistmodel.h
@@ -8,6 +8,7 @@
 #include <interfaces/wallet.h>
 #include <QAbstractListModel>
 #include <QList>
+#include <QString>
 
 namespace interfaces {
 class Node;
@@ -22,7 +23,9 @@ public:
     ~WalletListModel() = default;
 
     enum Roles {
-        NameRole = Qt::UserRole + 1
+        NameRole = Qt::UserRole + 1,
+        FormatRole,
+        NeedsMigrationRole,
     };
 
     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -35,6 +38,7 @@ public Q_SLOTS:
 private:
     struct Item {
         QString name;
+        QString format;
     };
 
     void addItem(const Item &item);
diff --git a/qml/pages/wallet/DesktopWallets.qml b/qml/pages/wallet/DesktopWallets.qml
index fd3a488bc..8beb671ed 100644
--- a/qml/pages/wallet/DesktopWallets.qml
+++ b/qml/pages/wallet/DesktopWallets.qml
@@ -88,6 +88,9 @@ Page {
                 onAddWallet: {
                     root.addWallet()
                 }
+                onWalletMigrationRequested: (walletPath) => {
+                    root.handleWalletMigrationRequired(walletPath)
+                }
             }
         }
         centerItem: RowLayout {
diff --git a/qml/pages/wallet/WalletSelect.qml b/qml/pages/wallet/WalletSelect.qml
index b525f4c6f..f40a3673f 100644
--- a/qml/pages/wallet/WalletSelect.qml
+++ b/qml/pages/wallet/WalletSelect.qml
@@ -18,6 +18,7 @@ Popup {
     clip: true
 
     signal addWallet()
+    signal walletMigrationRequested(string walletPath)
 
     background: Item {
         anchors.fill: parent
@@ -78,17 +79,22 @@ Popup {
 
             delegate: WalletBadge {
                 required property string name;
+                required property bool needsMigration;
                 objectName: "walletSelectItem_" + name
 
                 width: 220
                 height: 32
-                text: name
-                checked: walletController.selectedWallet.name == name
+                text: needsMigration ? qsTr("%1 (needs migration)").arg(name) : name
+                checked: !needsMigration && walletController.selectedWallet.name == name
                 ButtonGroup.group: buttonGroup
                 showBalance: false
                 showIcon: false
                 onClicked: {
-                    walletController.setSelectedWallet(name)
+                    if (needsMigration) {
+                        root.walletMigrationRequested(name)
+                    } else {
+                        walletController.setSelectedWallet(name)
+                    }
                     root.close()
                 }
             }
diff --git a/test/qml/qml_tests_main.cpp b/test/qml/qml_tests_main.cpp
index b4fcc9426..2bcfb7d4d 100644
--- a/test/qml/qml_tests_main.cpp
+++ b/test/qml/qml_tests_main.cpp
@@ -961,7 +961,9 @@ class MockWalletListModel : public QAbstractListModel
 
 public:
     enum Roles {
-        NameRole = Qt::UserRole + 1
+        NameRole = Qt::UserRole + 1,
+        FormatRole,
+        NeedsMigrationRole,
     };
 
     int rowCount(const QModelIndex& parent = QModelIndex{}) const override
@@ -974,12 +976,18 @@ public:
     {
         if (!index.isValid() || index.row() < 0 || index.row() >= m_wallet_names.size()) return {};
         if (role == NameRole) return m_wallet_names.at(index.row());
+        if (role == FormatRole) return QStringLiteral("sqlite");
+        if (role == NeedsMigrationRole) return false;
         return {};
     }
 
     QHash<int, QByteArray> roleNames() const override
     {
-        return {{NameRole, "name"}};
+        return {
+            {NameRole, "name"},
+            {FormatRole, "format"},
+            {NeedsMigrationRole, "needsMigration"},
+        };
     }
 
     Q_INVOKABLE void listWalletDir() {}
ACK 596fc76df48afc9830079d7a8c904cba4e2ef26d As a gui wallet flow, for unencrypted legacy wallets But the detection of legacy should be reworked, we currently do brittle string error matching to detect if migration is needed. We shouldn't be doing this and instead we should be using `m_node.walletLoader().listWalletDir()` and querying it's `info` return to see if the wallet is BDB, then expose this to qml. As the wallet controller is not being updated in this PR, this can be done in a separate PR. For example, the following patch should convey the idea (patch doesn't touch your string matching code) <details> ```diff diff --git a/qml/models/walletlistmodel.cpp b/qml/models/walletlistmodel.cpp index def378b7d..ead1e793b 100644 --- a/qml/models/walletlistmodel.cpp +++ b/qml/models/walletlistmodel.cpp @@ -6,8 +6,6 @@ #include <interfaces/node.h> -#include <QSet> - WalletListModel::WalletListModel(interfaces::Node& node, QObject *parent) : QAbstractListModel(parent) , m_node(node) @@ -16,17 +14,25 @@ WalletListModel::WalletListModel(interfaces::Node& node, QObject *parent) void WalletListModel::listWalletDir() { - QSet<QString> existing_names; - for (int i = 0; i < rowCount(); ++i) { - QModelIndex index = this->index(i, 0); - QString name = data(index, NameRole).toString(); - existing_names.insert(name); - } - - for (const auto& [path, info] : m_node.walletLoader().listWalletDir()) { + for (const auto& [path, format] : m_node.walletLoader().listWalletDir()) { QString qname = QString::fromStdString(path); - if (!existing_names.contains(qname)) { - addItem({ qname }); + QString qformat = QString::fromStdString(format); + bool found = false; + for (int i = 0; i < rowCount(); ++i) { + if (m_items[i].name != qname) { + continue; + } + found = true; + if (m_items[i].format != qformat) { + m_items[i].format = qformat; + const QModelIndex changed_index = index(i, 0); + Q_EMIT dataChanged(changed_index, changed_index, {FormatRole, NeedsMigrationRole}); + } + break; + } + + if (!found) { + addItem({ qname, qformat }); } } } @@ -47,6 +53,10 @@ QVariant WalletListModel::data(const QModelIndex &index, int role) const case Qt::DisplayRole: case NameRole: return item.name; + case FormatRole: + return item.format; + case NeedsMigrationRole: + return item.format == QStringLiteral("bdb"); default: return QVariant(); } @@ -56,6 +66,8 @@ QHash<int, QByteArray> WalletListModel::roleNames() const { QHash<int, QByteArray> roles; roles[NameRole] = "name"; + roles[FormatRole] = "format"; + roles[NeedsMigrationRole] = "needsMigration"; return roles; } diff --git a/qml/models/walletlistmodel.h b/qml/models/walletlistmodel.h index c36cb2b4f..13ae99037 100644 --- a/qml/models/walletlistmodel.h +++ b/qml/models/walletlistmodel.h @@ -8,6 +8,7 @@ #include <interfaces/wallet.h> #include <QAbstractListModel> #include <QList> +#include <QString> namespace interfaces { class Node; @@ -22,7 +23,9 @@ public: ~WalletListModel() = default; enum Roles { - NameRole = Qt::UserRole + 1 + NameRole = Qt::UserRole + 1, + FormatRole, + NeedsMigrationRole, }; int rowCount(const QModelIndex &parent = QModelIndex()) const override; @@ -35,6 +38,7 @@ public Q_SLOTS: private: struct Item { QString name; + QString format; }; void addItem(const Item &item); diff --git a/qml/pages/wallet/DesktopWallets.qml b/qml/pages/wallet/DesktopWallets.qml index fd3a488bc..8beb671ed 100644 --- a/qml/pages/wallet/DesktopWallets.qml +++ b/qml/pages/wallet/DesktopWallets.qml @@ -88,6 +88,9 @@ Page { onAddWallet: { root.addWallet() } + onWalletMigrationRequested: (walletPath) => { + root.handleWalletMigrationRequired(walletPath) + } } } centerItem: RowLayout { diff --git a/qml/pages/wallet/WalletSelect.qml b/qml/pages/wallet/WalletSelect.qml index b525f4c6f..f40a3673f 100644 --- a/qml/pages/wallet/WalletSelect.qml +++ b/qml/pages/wallet/WalletSelect.qml @@ -18,6 +18,7 @@ Popup { clip: true signal addWallet() + signal walletMigrationRequested(string walletPath) background: Item { anchors.fill: parent @@ -78,17 +79,22 @@ Popup { delegate: WalletBadge { required property string name; + required property bool needsMigration; objectName: "walletSelectItem_" + name width: 220 height: 32 - text: name - checked: walletController.selectedWallet.name == name + text: needsMigration ? qsTr("%1 (needs migration)").arg(name) : name + checked: !needsMigration && walletController.selectedWallet.name == name ButtonGroup.group: buttonGroup showBalance: false showIcon: false onClicked: { - walletController.setSelectedWallet(name) + if (needsMigration) { + root.walletMigrationRequested(name) + } else { + walletController.setSelectedWallet(name) + } root.close() } } diff --git a/test/qml/qml_tests_main.cpp b/test/qml/qml_tests_main.cpp index b4fcc9426..2bcfb7d4d 100644 --- a/test/qml/qml_tests_main.cpp +++ b/test/qml/qml_tests_main.cpp @@ -961,7 +961,9 @@ class MockWalletListModel : public QAbstractListModel public: enum Roles { - NameRole = Qt::UserRole + 1 + NameRole = Qt::UserRole + 1, + FormatRole, + NeedsMigrationRole, }; int rowCount(const QModelIndex& parent = QModelIndex{}) const override @@ -974,12 +976,18 @@ public: { if (!index.isValid() || index.row() < 0 || index.row() >= m_wallet_names.size()) return {}; if (role == NameRole) return m_wallet_names.at(index.row()); + if (role == FormatRole) return QStringLiteral("sqlite"); + if (role == NeedsMigrationRole) return false; return {}; } QHash<int, QByteArray> roleNames() const override { - return {{NameRole, "name"}}; + return { + {NameRole, "name"}, + {FormatRole, "format"}, + {NeedsMigrationRole, "needsMigration"}, + }; } Q_INVOKABLE void listWalletDir() {} ``` </details>
johnny9 commented 2026-05-14 04:18:26 +00:00 (Migrated from github.com)

I went ahead and reworked the flow to use the format string from the listWalletDir() call. I wasn't aware that the second string in the returned pair was actually the format and that could be used to decide on if migration is needed. This makes it way less fragile of a decision than trying to interpret error strings that may change.

Unit tests added to validate and original migration flow functional test is passing

I went ahead and reworked the flow to use the format string from the listWalletDir() call. I wasn't aware that the second string in the returned pair was actually the format and that could be used to decide on if migration is needed. This makes it way less fragile of a decision than trying to interpret error strings that may change. Unit tests added to validate and original migration flow functional test is passing
MarnixCroes (Migrated from github.com) approved these changes 2026-05-14 15:35:24 +00:00
MarnixCroes (Migrated from github.com) left a comment

tested ACK 09ba06cbc3

tested ACK 09ba06cbc35b27ca94ad1c1240f7538638f059b9
jarolrod commented 2026-05-14 16:39:01 +00:00 (Migrated from github.com)

ACK github.com/bitcoin-core/gui-qml@09ba06cbc3

Thanks for reworking our migration detection, the patch accomplishes what I said we should do here

I would make the description and title explicit that this is for unencrypted only.

ACK https://github.com/bitcoin-core/gui-qml/commit/09ba06cbc35b27ca94ad1c1240f7538638f059b9 Thanks for reworking our migration detection, the patch accomplishes what I said we should do [here](https://github.com/bitcoin-core/gui-qml/pull/539#pullrequestreview-4287111858) I would make the description and title explicit that this is for unencrypted only.
pseudoramdom (Migrated from github.com) reviewed 2026-05-14 17:31:55 +00:00
pseudoramdom (Migrated from github.com) commented 2026-05-14 17:31:55 +00:00

Can this be an enum since all of them are mutually exclusive states?

Can this be an enum since all of them are mutually exclusive states?
johnny9 (Migrated from github.com) reviewed 2026-05-14 17:36:11 +00:00
johnny9 (Migrated from github.com) commented 2026-05-14 17:36:11 +00:00

can switch this to using states

can switch this to using states
pseudoramdom (Migrated from github.com) reviewed 2026-05-14 17:43:44 +00:00
pseudoramdom (Migrated from github.com) commented 2026-05-14 17:43:44 +00:00

I ran in to this while trying to migrate wallet with passphrase.
Image

Does #548 cover this use case?

I ran in to this while trying to migrate wallet with passphrase. <img width="563" height="319" alt="Image" src="https://git.fish.foo/attachments/1c6c06bd-5f8e-41bb-b059-064504e4a27f" /> Does #548 cover this use case?
jarolrod (Migrated from github.com) reviewed 2026-05-14 17:45:23 +00:00
jarolrod (Migrated from github.com) commented 2026-05-14 17:45:23 +00:00

yeah this PR should make it explicit that its setting this up, and it currently only works for unencrypted.

Password PR is intended to then finish this feature

yeah this PR should make it explicit that its setting this up, and it currently only works for unencrypted. Password PR is intended to then finish this feature
johnny9 (Migrated from github.com) reviewed 2026-05-14 17:45:50 +00:00
johnny9 (Migrated from github.com) commented 2026-05-14 17:45:50 +00:00

i will switch to the state pattern as it is more organized but the enums dont provide value since we dont need type checking and they are functionally equivalent to strings

i will switch to the state pattern as it is more organized but the enums dont provide value since we dont need type checking and they are functionally equivalent to strings
pseudoramdom commented 2026-05-14 17:55:50 +00:00 (Migrated from github.com)

ACK b17fe2eead (migration for for unencrypted wallets)

ACK b17fe2eead02acf51424ed759c1f076753b03077 (migration for for unencrypted wallets)
pseudoramdom (Migrated from github.com) approved these changes 2026-05-14 17:57:13 +00:00
jarolrod commented 2026-05-14 18:07:51 +00:00 (Migrated from github.com)

ACK github.com/bitcoin-core/gui-qml@b17fe2eead

Changes since my last review is refactoring for states

ACK https://github.com/bitcoin-core/gui-qml/commit/b17fe2eead02acf51424ed759c1f076753b03077 Changes since my last review is refactoring for states
Sign in to join this conversation.
No description provided.