Introduce WalletModel and loadWallet functionality #417

Manually merged
johnny9 merged 3 commits from wallet-model into main 2024-12-16 09:18:18 +00:00 AGit
johnny9 commented 2024-08-23 14:27:22 +00:00 (Migrated from github.com)

When a user selects a wallet from the WalletSelect menu the wallet controller can now load the wallet data in and the name and balance will appear in the WalletBadge

The WalletQmlModel is introduced that hodes the interface to the backend wallet and provides the balance to the gui as a formatted string. The formatted string isn't quite as nice as specified in the figma. Instead it just uses the satoshi formatting currently provided by our GUI utils. The advanced formatting will be added as its own PR so that it can be reviewed separately.

WalletController has been renamed to WalletQmlController to not conflict with the qt widgets controller. A function to set the selected wallet has been added. This function loads or creates the backend wallet interface and a WalletQmlModel owns the interface and is set to the controller's selectedWallet property. This is how the gui will gain access to the wallet's information.

Loading encrypted wallets is not currently handled as we need additional dialogs. This will be done in a separate PR so that it can be reviewed independantly.

A handler is also added to the wallet controller to handle background loading of wallet either through the rpc interface or at startup.

Initial state and loading states of the wallet selector have not been implemented yet and will be done separately so it currently will just show 0 balance until a wallet is properly loaded.

When a user selects a wallet from the WalletSelect menu the wallet controller can now load the wallet data in and the name and balance will appear in the WalletBadge The WalletQmlModel is introduced that hodes the interface to the backend wallet and provides the balance to the gui as a formatted string. The formatted string isn't quite as nice as specified in the figma. Instead it just uses the satoshi formatting currently provided by our GUI utils. The advanced formatting will be added as its own PR so that it can be reviewed separately. WalletController has been renamed to WalletQmlController to not conflict with the qt widgets controller. A function to set the selected wallet has been added. This function loads or creates the backend wallet interface and a WalletQmlModel owns the interface and is set to the controller's selectedWallet property. This is how the gui will gain access to the wallet's information. Loading encrypted wallets is not currently handled as we need additional dialogs. This will be done in a separate PR so that it can be reviewed independantly. A handler is also added to the wallet controller to handle background loading of wallet either through the rpc interface or at startup. Initial state and loading states of the wallet selector have not been implemented yet and will be done separately so it currently will just show 0 balance until a wallet is properly loaded.
MarnixCroes commented 2024-08-23 16:02:06 +00:00 (Migrated from github.com)

forgot to push some stuff?
some things seem to be missing and CI is failing

forgot to push some stuff? some things seem to be missing and CI is failing
jarolrod (Migrated from github.com) reviewed 2024-09-11 03:41:55 +00:00
jarolrod (Migrated from github.com) left a comment

Concept ACK

This is a sufficient starting point, @johnny9 fix CI?

Concept ACK This is a sufficient starting point, @johnny9 fix CI?
MarnixCroes (Migrated from github.com) reviewed 2024-09-13 06:34:22 +00:00
MarnixCroes (Migrated from github.com) left a comment

df375c0c51ae0c4b3a8b059284cedbcc685acdc1

  • On regtest, I generated a wallet and did generatetoaddress 200
    Then the balance was displayed like this
    S

QT:
S

  • regularly it is rather slow or not working
    (it's not because they are big unused wallets that need to load, it works fine when using QT)

screencastload.webm

  • I've had a couple times that after closing the app the Saving... window stayed on for multiple minutes while there seems to be no reason as there was no heavy usage that needed to be saved, maybe related to previous point
df375c0c51ae0c4b3a8b059284cedbcc685acdc1 - On regtest, I generated a wallet and did generatetoaddress 200 Then the balance was displayed like this ![S](https://git.fish.foo/attachments/e384d847-f1db-4f69-98d0-712d0e43bc21) QT: ![S](https://git.fish.foo/attachments/a462211b-950e-4c1a-b97d-60950894ad90) - regularly it is rather slow or not working (it's not because they are big unused wallets that need to load, it works fine when using QT) [screencastload.webm](https://github.com/user-attachments/assets/109bc79d-ada9-4843-8bfd-89adaba94e1f) - I've had a couple times that after closing the app the `Saving...` window stayed on for multiple minutes while there seems to be no reason as there was no heavy usage that needed to be saved, maybe related to previous point
MarnixCroes (Migrated from github.com) reviewed 2024-09-23 08:03:23 +00:00
MarnixCroes (Migrated from github.com) left a comment

26b5ef9ae588e9b21acf1f9e05a3f498bb60049c
the negative balance issue is fixed

  • Sometimes it does, but oftenly it doesn't work as supposed

Screencast.webm

  • the balance doesn't update when balanceChanged
  • the shutting down window shows all the time now (indefinitely, many minutes, have to manually kill it) when shutting down from terminal, doesn't happen when clicking the X of the app
  • nit, some amount can be a bit cut off, same is for the wallet name
    image
26b5ef9ae588e9b21acf1f9e05a3f498bb60049c the negative balance issue is fixed - Sometimes it does, but oftenly it doesn't work as supposed [Screencast.webm](https://github.com/user-attachments/assets/b163aa51-1815-4d4b-adff-8f0ae80c41ee) - the balance doesn't update when balanceChanged - the shutting down window shows all the time now (indefinitely, many minutes, have to manually kill it) when shutting down from terminal, doesn't happen when clicking the X of the app - nit, some amount can be a bit cut off, same is for the wallet name ![image](https://git.fish.foo/attachments/e4617962-552f-4bc6-b1e2-cc891db8cb3a)
johnny9 commented 2024-09-24 02:01:40 +00:00 (Migrated from github.com)

update from 26b5ef9 to d155eed

  • Unloaded wallets when shutdown is requested.
update from 26b5ef9 to[ d155eed](https://github.com/bitcoin-core/gui-qml/commit/d155eedd5680cc2e07a0a932ec68cb8023ededd4) - Unloaded wallets when shutdown is requested.
jarolrod (Migrated from github.com) reviewed 2024-09-25 10:13:52 +00:00
jarolrod (Migrated from github.com) left a comment

ACK d155eedd5680cc2e07a0a932ec68cb8023ededd4

This is fine as the initial template for the models and controller, balanceChanged is not properly wired.

I would say the idea of loading is not yet finished, we should implement the functionality of loading an encrypted wallet next.

ACK d155eedd5680cc2e07a0a932ec68cb8023ededd4 This is fine as the initial template for the models and controller, `balanceChanged` is not properly wired. I would say the idea of loading is not yet finished, we should implement the functionality of loading an encrypted wallet next.
jarolrod (Migrated from github.com) commented 2024-09-25 10:12:55 +00:00

this leaves the wallet dropdown in a weird looking state, we'd want to revisit balance anyways on subsequent updates, just noting that this should all change.

this leaves the wallet dropdown in a weird looking state, we'd want to revisit balance anyways on subsequent updates, just noting that this should all change.
jarolrod (Migrated from github.com) commented 2024-09-25 10:13:38 +00:00

I guess we'll also need the sat symbol :P

I guess we'll also need the sat symbol :P
hebasto commented 2024-09-27 19:27:19 +00:00 (Migrated from github.com)

Concept ACK.

Concept ACK.
johnny9 commented 2024-10-20 00:56:47 +00:00 (Migrated from github.com)

Update from d155eed to b41a0e4

  • Additional #ifdef to exclude functionality when --disable-wallet
Update from d155eed to[ b41a0e4](https://github.com/bitcoin-core/gui-qml/commit/b41a0e4e05b4bc1751f207ac7673f96684764e5c) - Additional #ifdef to exclude functionality when --disable-wallet
MarnixCroes (Migrated from github.com) reviewed 2024-10-20 08:33:49 +00:00
MarnixCroes (Migrated from github.com) left a comment

b41a0e4e05

it sometimes happens that the walletname shown as loaded in the navigationbar is not the same as the wallet shown as loaded/selected in the wallet select dropdown

Screencast

as a result, clicking another wallet doesn't seem to work as it doesn't update the selected walletname in navbar

b41a0e4e05b4bc1751f207ac7673f96684764e5c it sometimes happens that the walletname shown as loaded in the navigationbar is not the same as the wallet shown as loaded/selected in the wallet select dropdown [Screencast ](https://github.com/user-attachments/assets/8b57a0ab-100e-4ce7-a080-04c04f514a0c) as a result, clicking another wallet doesn't seem to work as it doesn't update the selected walletname in navbar
pablomartin4btc (Migrated from github.com) reviewed 2024-11-02 01:56:55 +00:00
pablomartin4btc (Migrated from github.com) left a comment

tested manually b41a0e4e05 in -regtest

As soon as bitcoin-qt starts, it seems that loading the latest used wallet is quite slow and takes like 5 secs to show it up on the menu.

Also it's very slow to load/ switch to another wallet (and only non/ 0 balance wallets), for wallets with some balance (using -regtest), doesn't work at all (selected wallet doesn't change so balance either).

Last thing for now, in Qt we have the list of wallets in the file menu to select and load and when there are more then 1 wallet loaded (multi-wallet mode) there's combo box with the loaded wallets to switch between them. I think the designers or Christoph showed me some prototype where there were small icons in the list to indicate which wallet is loaded or not, perhaps it should be another icon/ button to select only the loaded wallets, unloaded or both/ all.

tested manually b41a0e4e05b4bc1751f207ac7673f96684764e5c in `-regtest` As soon as `bitcoin-qt` starts, it seems that loading the latest used wallet is quite slow and takes like 5 secs to show it up on the menu. Also it's very slow to load/ switch to another wallet (and only non/ 0 balance wallets), for wallets with some balance (using `-regtest`), doesn't work at all (selected wallet doesn't change so balance either). Last thing for now, in Qt we have the list of wallets in the file menu to select and load and when there are more then 1 wallet loaded (multi-wallet mode) there's combo box with the loaded wallets to switch between them. I think the designers or Christoph showed me some prototype where there were small icons in the list to indicate which wallet is loaded or not, perhaps it should be another icon/ button to select only the loaded wallets, unloaded or both/ all.
johnny9 commented 2024-11-25 18:53:40 +00:00 (Migrated from github.com)

All of the issues commented so far are going to explode the complexity of this PR beyond anything reviewable. I just wanted to create the boilerplate for the classes that the UI will interact with. Each of the above issues should be a separate PR as thate functionality gets added to the GUI.

The only thing this is intended to do is list the wallets in the folder and when one is selected it loads and shows the very basic formatted balance. The more advanced formatting, for instance, should be added and reviewed in its own PR as well as they asynchronous loading and event handling.

Edit: I went ahead and solved the issue with work being done on the gui thread. The creation is now done on QThread m_worker_thread.

All of the issues commented so far are going to explode the complexity of this PR beyond anything reviewable. I just wanted to create the boilerplate for the classes that the UI will interact with. Each of the above issues should be a separate PR as thate functionality gets added to the GUI. The only thing this is intended to do is list the wallets in the folder and when one is selected it loads and shows the very basic formatted balance. The more advanced formatting, for instance, should be added and reviewed in its own PR as well as they asynchronous loading and event handling. Edit: I went ahead and solved the issue with work being done on the gui thread. The creation is now done on QThread m_worker_thread.
johncarl-te (Migrated from github.com) reviewed 2024-11-27 15:48:34 +00:00
johncarl-te (Migrated from github.com) commented 2024-11-27 15:48:34 +00:00

yeah the wallet badge needs more states and will be one of the next things to tackle in the wallet selector component.

yeah the wallet badge needs more states and will be one of the next things to tackle in the wallet selector component.
jarolrod (Migrated from github.com) reviewed 2024-12-10 01:15:32 +00:00
jarolrod (Migrated from github.com) left a comment

ACK 50c5f87552

I wouldn't reuse any Qt util functions but i can understand why we would want to keep this for a follow-up in order to evaluate things independently. There are many things to be done, but as the code, title, and description states this is all quite scoped and focused on specifically introducing a WalletModel and loadwallet functionality.

The WalletQMLController being where properties are provided to the GUI works for now, and we can reevaluate as we build out more complexity.

ACK 50c5f87552b6bf9d56840b91cdf0ea58f1ec862d I wouldn't reuse any Qt util functions but i can understand why we would want to keep this for a follow-up in order to evaluate things independently. There are many things to be done, but as the code, title, and description states this is all quite scoped and focused on specifically introducing a WalletModel and loadwallet functionality. The WalletQMLController being where properties are provided to the GUI works for now, and we can reevaluate as we build out more complexity.
Sign in to join this conversation.
No description provided.