Skip to content

Commit 3fd0c23

Browse files
committed
Merge #13273: Qt/Bugfix: fix handling default wallet with no name
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
2 parents 56fe3dc + 13c3a65 commit 3fd0c23

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
312312
std::string method = stack.back()[0];
313313
std::string uri;
314314
#ifdef ENABLE_WALLET
315-
if (walletID && !walletID->empty()) {
315+
if (walletID) {
316316
QByteArray encodedName = QUrl::toPercentEncoding(QString::fromStdString(*walletID));
317317
uri = "/wallet/"+std::string(encodedName.constData(), encodedName.length());
318318
}
@@ -425,7 +425,7 @@ void RPCExecutor::request(const QString &command, const QString &walletID)
425425
return;
426426
}
427427
std::string wallet_id = walletID.toStdString();
428-
if(!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, &wallet_id))
428+
if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, walletID.isNull() ? nullptr : &wallet_id))
429429
{
430430
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
431431
return;
@@ -910,7 +910,7 @@ void RPCConsole::on_lineEdit_returnPressed()
910910
}
911911

912912
if (m_last_wallet_id != walletID) {
913-
if (walletID.isEmpty()) {
913+
if (walletID.isNull()) {
914914
message(CMD_REQUEST, tr("Executing command without any wallet"));
915915
} else {
916916
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(walletID));

0 commit comments

Comments
 (0)