Skip to content

Conversation

jonasschnelli
Copy link
Contributor

If one loads a wallet via RPC (loadwallet w2), then select w2, select back to the default wallet (which is an empty string), that default wallet cannot be access through the RPC console because the current code only points to the wallet endpoint if the wallet name is not empty.

This is a quick fix that reenables accessing the default wallet in case an additional wallet has been loaded.

Using "" for the default wallet may not be ideal in other cases and it may make more sense to change it at a deeper level (wallet.cpp). See discussion here which where the reasons for the current behaviour in master:
#11687 (comment)

@jnewbery @promag @ryanofsky

@jonasschnelli jonasschnelli force-pushed the 2018/05/loadwallet_fix branch 2 times, most recently from 3ac1fb2 to 3033bf9 Compare May 18, 2018 12:05
@promag
Copy link
Contributor

promag commented May 18, 2018

utACK 3033bf9, it is now possible to use the default wallet in the console.

Please see fe9beca as an alternative and smaller fix.

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK for both 3033bf9c5354f710d5f18fbcdb3a48ec16fe98ff and fe9beca. Promag's fix in fe9beca seems simpler and more elegant though, so maybe it would be good to reset this PR to that change and merge it.

@@ -425,7 +425,7 @@ void RPCExecutor::request(const QString &command, const QString &walletID)
return;
}
std::string wallet_id = walletID.toStdString();
if(!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, &wallet_id))
if(!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, (use_wallet) ? &wallet_id : nullptr))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parentheses around use_wallet seem odd

@jonasschnelli jonasschnelli force-pushed the 2018/05/loadwallet_fix branch from 3033bf9 to 13c3a65 Compare May 18, 2018 18:03
@jonasschnelli
Copy link
Contributor Author

jonasschnelli commented May 18, 2018

Switch to fe9beca which is the better approach... I have thought, similar to std::string, there is no concept of nullness for QStrings.

@jnewbery
Copy link
Contributor

utACK 13c3a65

1 similar comment
@laanwj
Copy link
Member

laanwj commented May 29, 2018

utACK 13c3a65

@laanwj laanwj merged commit 13c3a65 into bitcoin:master May 29, 2018
laanwj added a commit that referenced this pull request May 29, 2018
13c3a65 Qt/Bugfix: fix handling default wallet with no name (João Barbosa)

Pull request description:

  If one loads a wallet via RPC (`loadwallet w2`), then select w2, select back to the default wallet (which is an empty string), that default wallet cannot be access through the RPC console because the current code only points to the wallet endpoint if the wallet name is not empty.

  This is a quick fix that reenables accessing the default wallet in case an additional wallet has been loaded.

  Using "" for the default wallet may not be ideal in other cases and it may make more sense to change it at a deeper level (wallet.cpp). See discussion here which where the reasons for the current behaviour in master:
  #11687 (comment)

  @jnewbery @promag @ryanofsky

Tree-SHA512: 74b935886b4e4a6033a2f5e1f44bb69a252e31f4021e19a2054445a8e3e4db1d8ee256290850a84d8569d2d0e21412fce0170e7f0e881259156057587181ee05
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 25, 2019
Summary:
13c3a65 Qt/Bugfix: fix handling default wallet with no name (João Barbosa)

Pull request description:

  If one loads a wallet via RPC (`loadwallet w2`), then select w2, select back to the default wallet (which is an empty string), that default wallet cannot be access through the RPC console because the current code only points to the wallet endpoint if the wallet name is not empty.

  This is a quick fix that reenables accessing the default wallet in case an additional wallet has been loaded.

  Using "" for the default wallet may not be ideal in other cases and it may make more sense to change it at a deeper level (wallet.cpp). See discussion here which where the reasons for the current behaviour in master:
  bitcoin/bitcoin#11687 (comment)

  @jnewbery @promag @ryanofsky

Tree-SHA512: 74b935886b4e4a6033a2f5e1f44bb69a252e31f4021e19a2054445a8e3e4db1d8ee256290850a84d8569d2d0e21412fce0170e7f0e881259156057587181ee05

Backport of Core PR13273
bitcoin/bitcoin#13273

Test Plan:
This patch is not fully testable without D4236, but it fixes a bug that is not usually visible without dynamically loadable wallets.
  arc patch D4236
  arc patch D4245 (this patch)
  make check
  ./bitcoin-qt
  Help -> Debug -> Console
  loadwallet ""
Pre patch, this would crash the gui
Post patch, this should simply fail

  createwallet test
  Make sure the default wallet is selected
  getwalletinfo
Pre patch this would fail with the following error:
  Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).  (code -19)
Post patch, this will succeed.

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D4245
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 16, 2020
13c3a65 Qt/Bugfix: fix handling default wallet with no name (João Barbosa)

Pull request description:

  If one loads a wallet via RPC (`loadwallet w2`), then select w2, select back to the default wallet (which is an empty string), that default wallet cannot be access through the RPC console because the current code only points to the wallet endpoint if the wallet name is not empty.

  This is a quick fix that reenables accessing the default wallet in case an additional wallet has been loaded.

  Using "" for the default wallet may not be ideal in other cases and it may make more sense to change it at a deeper level (wallet.cpp). See discussion here which where the reasons for the current behaviour in master:
  bitcoin#11687 (comment)

  @jnewbery @promag @ryanofsky

Tree-SHA512: 74b935886b4e4a6033a2f5e1f44bb69a252e31f4021e19a2054445a8e3e4db1d8ee256290850a84d8569d2d0e21412fce0170e7f0e881259156057587181ee05
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 18, 2020
13c3a65 Qt/Bugfix: fix handling default wallet with no name (João Barbosa)

Pull request description:

  If one loads a wallet via RPC (`loadwallet w2`), then select w2, select back to the default wallet (which is an empty string), that default wallet cannot be access through the RPC console because the current code only points to the wallet endpoint if the wallet name is not empty.

  This is a quick fix that reenables accessing the default wallet in case an additional wallet has been loaded.

  Using "" for the default wallet may not be ideal in other cases and it may make more sense to change it at a deeper level (wallet.cpp). See discussion here which where the reasons for the current behaviour in master:
  bitcoin#11687 (comment)

  @jnewbery @promag @ryanofsky

Tree-SHA512: 74b935886b4e4a6033a2f5e1f44bb69a252e31f4021e19a2054445a8e3e4db1d8ee256290850a84d8569d2d0e21412fce0170e7f0e881259156057587181ee05
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants