[Qt] Use wallet 0 in rpc console if running with multiple wallets #10870

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2017/07/qt_mw changing 1 files +9 −0
  1. jonasschnelli commented at 6:25 PM on July 18, 2017: contributor

    Current master with multiwallet results in accessing wallet 0 in QT (send / receive / tx history / etc.), but the RPC console cannot access that wallet (only non-wallet commands work).

    This is a quick solution to re-allow accessing the same wallet (Index 0) via RPC console in multiwallet.

    The solutions design is not "state of the art" (should go over WalletModel). Ideally we work on an overall multiwallet support for the GUI (which then would remove this change).

    I think we should consider this as a bugfix.

  2. jonasschnelli added the label GUI on Jul 18, 2017
  3. laanwj added this to the milestone 0.15.0 on Jul 19, 2017
  4. in src/qt/rpcconsole.cpp:308 in 2044595484 outdated
     301 | @@ -301,6 +302,14 @@ bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &
     302 |                              JSONRPCRequest req;
     303 |                              req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
     304 |                              req.strMethod = stack.back()[0];
     305 | +#ifdef ENABLE_WALLET
     306 | +                            // TODO: Move this logic to WalletModel
     307 | +                            if (vpwallets.size() > 1)
     308 | +                            {
    


    promag commented at 9:40 PM on July 19, 2017:

    Nit, same line as if.


    jonasschnelli commented at 6:54 AM on July 20, 2017:

    I think we should keep the TODO to make sure we clean that up asap (once 0.15 has been split off).


    laanwj commented at 3:09 PM on July 20, 2017:

    Wouldn't this be safe to do for vpwallets.size()==1 too? If so, I'd slightly prefer that, because it means this code is always used when wallet is enabled.

  5. promag commented at 9:49 PM on July 19, 2017: member

    Tested ACK 2044595. Is this WIP (because of the TODO) or final?

  6. [Qt] Use wallet 0 in rpc console if running with multiple wallets 97375727b8
  7. in src/qt/rpcconsole.cpp:310 in 2044595484 outdated
     301 | @@ -301,6 +302,14 @@ bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &
     302 |                              JSONRPCRequest req;
     303 |                              req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
     304 |                              req.strMethod = stack.back()[0];
     305 | +#ifdef ENABLE_WALLET
     306 | +                            // TODO: Move this logic to WalletModel
     307 | +                            if (vpwallets.size() > 1)
     308 | +                            {
     309 | +                                // in Qt, use always the wallet with index 0 when running with multiple wallets
     310 | +                                req.URI = "/wallet/"+QUrl(QString::fromStdString(vpwallets[0]->GetName())).toString().toStdString();
    


    laanwj commented at 3:20 PM on July 20, 2017:

    What about

    QByteArray encodedName = QUrl::toPercentEncoding(QString::fromStdString(vpwallets[0]->GetName())));
    req.URI = "wallet/"+std::string(encodedName.constData(), encodedName.length());
    

    Still fairly ugly, but this makes it clear that the point is to URL-encode (percent encode) the wallet name. Not convinced that passing a string into QUrl() does the right thing in all cases.

  8. jonasschnelli force-pushed on Jul 20, 2017
  9. jonasschnelli commented at 6:25 PM on July 20, 2017: contributor

    Implemented @laanwj's recommendation, fixed @promag's nit.

  10. promag commented at 3:24 PM on July 21, 2017: member

    Tested ACK 9737572.

  11. laanwj merged this on Jul 25, 2017
  12. laanwj closed this on Jul 25, 2017

  13. laanwj referenced this in commit 412b466d11 on Jul 25, 2017
  14. PastaPastaPasta referenced this in commit b2b0bc9b0a on Aug 2, 2019
  15. PastaPastaPasta referenced this in commit 455b610ba0 on Aug 6, 2019
  16. barrystyle referenced this in commit c9c0cd70ea on Jan 22, 2020
  17. random-zebra referenced this in commit 2d50b6e3b9 on Jun 9, 2021
  18. DrahtBot locked this on Sep 8, 2021
Labels

Milestone
0.15.0


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: 2026-04-21 18:15 UTC

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