Skip to content

Commit 412b466

Browse files
committed
Merge #10870: [Qt] Use wallet 0 in rpc console if running with multiple wallets
9737572 [Qt] Use wallet 0 in rpc console if running with multiple wallets (Jonas Schnelli) Pull request description: 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. Tree-SHA512: 16cf844662248ffd3d82c7d0cbe5879f231fbc7d4f5a4aab4180a9087018519c98301e4ac311eaec2cc39dddf25d3edf9be99a6622ea682c138a820a9b21fd0c
2 parents 1124328 + 9737572 commit 412b466

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/qt/rpcconsole.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#ifdef ENABLE_WALLET
2727
#include <db_cxx.h>
28+
#include <wallet/wallet.h>
2829
#endif
2930

3031
#include <QKeyEvent>
@@ -301,6 +302,14 @@ bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &
301302
JSONRPCRequest req;
302303
req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
303304
req.strMethod = stack.back()[0];
305+
#ifdef ENABLE_WALLET
306+
// TODO: Move this logic to WalletModel
307+
if (!vpwallets.empty()) {
308+
// in Qt, use always the wallet with index 0 when running with multiple wallets
309+
QByteArray encodedName = QUrl::toPercentEncoding(QString::fromStdString(vpwallets[0]->GetName()));
310+
req.URI = "/wallet/"+std::string(encodedName.constData(), encodedName.length());
311+
}
312+
#endif
304313
lastResult = tableRPC.execute(req);
305314
}
306315

0 commit comments

Comments
 (0)