Multiwallet for the GUI #12610

pull jonasschnelli wants to merge 12 commits into bitcoin:master from jonasschnelli:2018/03/multiwallet changing 17 files +209 −63
  1. jonasschnelli commented at 5:24 am on March 6, 2018: contributor

    This is an overhaul of #11383 (plus some additions). It avoids unnecessary coupling of httpserver/jsonrpc and the wallet as well as it avoids pointer pure passing (and pointer deletion) of CWallet (plus other minor design changes).

    Additionally it adds the wallet name to the sendconfirmation and request dialog (in case multiwallet is active)

  2. Qt: Load all wallets into WalletModels 3dba3c3ac1
  3. Qt: Add a combobox to toolbar to select from multiple wallets e449f9a9e6
  4. Qt: Ensure UI updates only come from the currently selected walletView 85d5319716
  5. Bugfix: RPC: Add missing UnregisterHTTPHandler for /wallet/ d558f44c58
  6. jonasschnelli added the label GUI on Mar 6, 2018
  7. jonasschnelli force-pushed on Mar 6, 2018
  8. in src/qt/bitcoingui.cpp:549 in 98cce65601 outdated
    546+    const QString name = walletModel->getWalletName();
    547     setWalletActionsEnabled(true);
    548-    return walletFrame->addWallet(name, walletModel);
    549+    m_wallet_selector->addItem(name);
    550+    if (m_wallet_selector->count() == 2) {
    551+        m_wallet_selector_label = new QLabel();
    


    Sjors commented at 3:34 pm on March 6, 2018:
    The first item in the menu is now created in the UI file, while new ones are created programatically. Can you make them all programmatically or maybe find a way to clone elements? Can be done in a future PR too.
  9. in src/qt/walletmodel.cpp:760 in 98cce65601 outdated
    755+    return walletName;
    756+}
    757+
    758+bool WalletModel::isMultiwallet()
    759+{
    760+    return gArgs.GetArgs("-wallet").size() > 1;
    


    Sjors commented at 3:41 pm on March 6, 2018:
    Why is this a method on WalletModel? Otherwise you could use m_wallet_models->count(). Maybe we need a WalletsModel class to hold on to a series of wallets?

    jonasschnelli commented at 1:58 am on March 7, 2018:
    I think the best place for wallets manager functions like this is currently the WalletModel, long term, we may want to have a WalletsManager (see #12587).
  10. in src/qt/bitcoingui.cpp:1010 in 98cce65601 outdated
    1008     QString msg = tr("Date: %1\n").arg(date) +
    1009-                  tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true)) +
    1010-                  tr("Type: %1\n").arg(type);
    1011+                  tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
    1012+    if (WalletModel::isMultiwallet() && !walletName.isEmpty())  {
    1013+        msg += tr("Wallet: %1\n").arg(walletName);
    


    Sjors commented at 4:00 pm on March 6, 2018:
    Seems to need a line break above:

    promag commented at 3:08 pm on March 14, 2018:
    It’s fixed right? At least there’s \n in the Amount: above.
  11. Sjors commented at 4:11 pm on March 6, 2018: member

    I still think it’s better to use the menu rather than add a dropbox, but as long as it’s easy to change later it doesn’t matter. I left some comments to better separate UI from model to make such a change easier. That already improved in this PR compared to #11383.

    Nit: “Loading wallet” should be “Loading wallets” if there’s more than 1.

  12. laanwj added this to the "Blockers" column in a project

  13. luke-jr commented at 6:53 pm on March 6, 2018: member

    This is strictly an inferior design to #11383, which already has ACKs and is ready for merging as-is.

    The minor other improvements can be done on top of that.

  14. Sjors commented at 10:16 pm on March 6, 2018: member
    @luke-jr it’s not strictly better; this PR has a cleaner separation of model and view. I can’t speak to the other differences.
  15. fanquake added this to the "In progress" column in a project

  16. laanwj commented at 4:58 pm on March 12, 2018: member
    Let’s stop arguing just for sake of arguing and help move this forward. If this is not the perfect design I’m sure it can be improved in a later PR. I’ll test it later.
  17. luke-jr commented at 5:05 pm on March 12, 2018: member
    Why does stop arguing mean merging this PR? #11383 is already reviewed and ready to merge…
  18. promag commented at 2:50 pm on March 14, 2018: member
    Should rebase to have external wallet support (#11687).
  19. in src/qt/sendcoinsdialog.cpp:283 in ba7090ee24 outdated
    276@@ -277,8 +277,11 @@ void SendCoinsDialog::on_sendButton_clicked()
    277     QStringList formatted;
    278     for (const SendCoinsRecipient &rcp : currentTransaction.getRecipients())
    279     {
    280-        // generate bold amount string
    281+        // generate bold amount string with wallet name in case of multiwallet
    282         QString amount = "<b>" + BitcoinUnits::formatHtmlWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
    283+        if (model->isMultiwallet()) {
    284+            amount.append(" <u>"+tr("from wallet %1").arg(GUIUtil::HtmlEscape(model->getWalletName()))+"</u> ");
    


    promag commented at 3:04 pm on March 14, 2018:
    Not sure about the underline, it’s already bold.

    jonasschnelli commented at 8:49 am on March 18, 2018:
    I think its okay since the used wallet is a pretty critical information. Overhauling the send-confirmation dialog is something that would be possible in the long run.
  20. in src/qt/bitcoingui.cpp:1008 in a055b1092e outdated
    1006     // On new transaction, make an info balloon
    1007     QString msg = tr("Date: %1\n").arg(date) +
    1008-                  tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true)) +
    1009-                  tr("Type: %1\n").arg(type);
    1010+                  tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
    1011+    if (WalletModel::isMultiwallet() && !walletName.isEmpty())  {
    


    promag commented at 3:07 pm on March 14, 2018:
    nit, remove extra space before {.
  21. promag commented at 3:11 pm on March 14, 2018: member

    Tested ACK.

    Receiving addresses and Sending addresses dialogs could have the wallet name in the dialog title.

  22. promag commented at 0:57 am on March 15, 2018: member
    Maybe running with -disablewallet should not show the wallet selector? Currently looks like:
  23. jonasschnelli force-pushed on Mar 18, 2018
  24. jonasschnelli commented at 8:45 am on March 18, 2018: contributor
    Added a commit that fixes the -disablewallet case (also won’t show the RPCConsole wallet selector if only one wallet is present).
  25. fanquake commented at 3:54 pm on March 21, 2018: member

    Testing https://github.com/bitcoin/bitcoin/pull/12610/commits/3b156cf01fda530cca127079d630c295d839efc1 on top of master (https://github.com/bitcoin/bitcoin/commit/4ad3b3c72c73d61e0a0cab541dca20acf651320d). macOS 10.13.3, Qt 5.10.1 Wallet Selector: selector

    In the debug console if I try and use the help command with either wallet selected I get an error. Selecting (none) and using help works fine: console

  26. in src/qt/walletmodel.cpp:752 in 3b156cf01f outdated
    743@@ -743,3 +744,18 @@ int WalletModel::getDefaultConfirmTarget() const
    744 {
    745     return nTxConfirmTarget;
    746 }
    747+
    748+QString WalletModel::getWalletName() const
    749+{
    750+    LOCK(wallet->cs_wallet);
    751+    QString walletName = QString::fromStdString(wallet->GetName());
    752+    if (walletName.endsWith(".dat")) {
    


    jnewbery commented at 7:26 pm on March 21, 2018:

    I’m not sure that we should strip .dat from the wallet name now that #11687 is merged. Perhaps @ryanofsky has an opinion on this?

    Also note that new default wallets will have the name "" (the empty string). Perhaps QT should display something different in this case?

    EDIT: for now, I think the only way we can have the default wallet with its name set to "" is if we start bitcoin with no wallet arguments, in which case multiwallet isn’t active and the dropdown won’t appear. However, in future we’ll have dynamic wallet loading/unloading, in which case we could have the default "" wallet plus named wallets.


    promag commented at 9:21 am on March 26, 2018:
    Good point. For sure something to deal with later.
  27. in src/qt/rpcconsole.cpp:308 in 3b156cf01f outdated
    303@@ -303,10 +304,9 @@ bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &
    304                             req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
    305                             req.strMethod = stack.back()[0];
    306 #ifdef ENABLE_WALLET
    307-                            // TODO: Move this logic to WalletModel
    308-                            if (!vpwallets.empty()) {
    309+                            if (walletID && !walletID->empty()) {
    310                                 // in Qt, use always the wallet with index 0 when running with multiple wallets
    


    jnewbery commented at 8:20 pm on March 21, 2018:
    I think this comment is outdated and can be removed
  28. jnewbery commented at 8:47 pm on March 21, 2018: member

    Tested ACK 3b156cf01fda530cca127079d630c295d839efc1, although I’m not very familiar with the qt code.

    To aid review, the commits could be tidied up a little (some code is added and removed in a later commit) and squashed a bit.

    A couple of comments inline.

  29. promag commented at 9:27 am on March 26, 2018: member

    Tested ACK 3b156cf.

    Running with -disablewallet works as expected and @fanquake point is fixed. Agree with @jnewbery that commits could be tidied up a little, but I don’t think that it should block this anymore.

  30. Qt: Add wallet selector to debug console d49cc70e6d
  31. Qt: QComboBox::setVisible doesn't work in toolbars, so defer adding it at all until needed d1ec34a761
  32. Qt: When multiple wallets are used, include in notifications the name 12d8d2681e
  33. Qt: Get wallet name from WalletModel rather than passing it around b6d04fc7cc
  34. GUI: RPCConsole: Log wallet changes cfa4133ce5
  35. Qt: show wallet name in send confirmation dlg in case of multiwallet 4826ca4b84
  36. Qt: show wallet name in request dlg in case of multiwallet dc6f150f35
  37. Qt: hide RPCConsole wallet selector when no wallets are present 779c5f9840
  38. jonasschnelli force-pushed on Mar 26, 2018
  39. jonasschnelli commented at 11:43 am on March 26, 2018: contributor
    Force push fixed the outdated commit. Can be verified by comparing 3b156cf01fda530cca127079d630c295d839efc1 against 779c5f984064cfc48304b78da664de13fc3d9bb4.
  40. jonasschnelli merged this on Mar 26, 2018
  41. jonasschnelli closed this on Mar 26, 2018

  42. jonasschnelli referenced this in commit 25cf18f239 on Mar 26, 2018
  43. instagibbs commented at 7:11 pm on March 26, 2018: member

    argh, sorry for the late review

    this logic here means that anytime we do a wallet match on rpc debug console, it will not find the wallet unless it has no .dat extension: https://github.com/bitcoin/bitcoin/pull/12610/commits/3dba3c3ac1679cf0086ee7734eee12268004ace7#diff-8c9d79ba40bf702f01685008550ac100R491

    This also means you can load two wallets(eg wallet.dat and wallet), and they will look the same in the drop down selector.

    imo if we’re supporting arbitrary filename extensions we should just display the entire name

  44. ryanofsky commented at 7:20 pm on March 26, 2018: member

    imo if we’re supporting arbitrary filename extensions we should just display the entire name

    Agree, it would be good to drop the special .dat extension handling (which is now in WalletModel::getWalletName().

  45. jnewbery commented at 8:31 pm on March 26, 2018: member
    I also agree that we should remove the special .dat extension handling
  46. luke-jr commented at 10:33 pm on March 26, 2018: member
    Totally un-user-friendly. If we merged #11383 without the ugly regressions herein, it wouldn’t have been a problem…
  47. fanquake removed this from the "Blockers" column in a project

  48. jonasschnelli moved this from the "In progress" to the "Done" column in a project

  49. deadalnix referenced this in commit f957f5b34c on Jan 10, 2019
  50. PastaPastaPasta referenced this in commit 8a62412558 on May 14, 2020
  51. PastaPastaPasta referenced this in commit 10b0549bfd on Jul 12, 2020
  52. PastaPastaPasta referenced this in commit 8d4f66cd09 on Jul 12, 2020
  53. PastaPastaPasta referenced this in commit 147101bc5c on Jul 16, 2020
  54. PastaPastaPasta referenced this in commit 2af7ce84fb on Jul 20, 2020
  55. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me