You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

multiwallet-qt.md 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. Multiwallet Qt Development and Integration Strategy
  2. ===================================================
  3. In order to support loading of multiple wallets in bitcoin-qt, a few changes in the UI architecture will be needed.
  4. Fortunately, only four of the files in the existing project are affected by this change.
  5. Two new classes have been implemented in two new .h/.cpp file pairs, with much of the functionality that was previously
  6. implemented in the BitcoinGUI class moved over to these new classes.
  7. The two existing files most affected, by far, are bitcoingui.h and bitcoingui.cpp, as the BitcoinGUI class will require
  8. some major retrofitting.
  9. Only requiring some minor changes is bitcoin.cpp.
  10. Finally, two new headers and source files will have to be added to bitcoin-qt.pro.
  11. Changes to class BitcoinGUI
  12. ---------------------------
  13. The principal change to the BitcoinGUI class concerns the QStackedWidget instance called centralWidget.
  14. This widget owns five page views: overviewPage, transactionsPage, addressBookPage, receiveCoinsPage, and sendCoinsPage.
  15. A new class called *WalletView* inheriting from QStackedWidget has been written to handle all renderings and updates of
  16. these page views. In addition to owning these five page views, a WalletView also has a pointer to a WalletModel instance.
  17. This allows the construction of multiple WalletView objects, each rendering a distinct wallet.
  18. A second class called *WalletFrame* inheriting from QFrame has been written as a container for embedding all wallet-related
  19. controls into BitcoinGUI. At present it contains the WalletView instances for the wallets and does little more than passing on messages
  20. from BitcoinGUI to the currently selected WalletView. It is a WalletFrame instance
  21. that takes the place of what used to be centralWidget in BitcoinGUI. The purpose of this class is to allow future
  22. refinements of the wallet controls with minimal need for further modifications to BitcoinGUI, thus greatly simplifying
  23. merges while reducing the risk of breaking top-level stuff.
  24. Changes to bitcoin.cpp
  25. ----------------------
  26. bitcoin.cpp is the entry point into bitcoin-qt, and as such, will require some minor modifications to provide hooks for
  27. multiple wallet support. Most importantly will be the way it instantiates WalletModels and passes them to the
  28. singleton BitcoinGUI instance called window. Formerly, BitcoinGUI kept a pointer to a single instance of a WalletModel.
  29. The initial change required is very simple: rather than calling `window.setWalletModel(&walletModel);` we perform the
  30. following two steps:
  31. window.addWallet("~Default", &walletModel);
  32. window.setCurrentWallet("~Default");
  33. The string parameter is just an arbitrary name given to the default wallet. It's been prepended with a tilde to avoid name collisions in the future with additional wallets.
  34. The shutdown call `window.setWalletModel(0)` has also been removed. In its place is now:
  35. window.removeAllWallets();