Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Basic Multiwallet GUI support #11383
Conversation
fanquake
added
GUI
Wallet
labels
Sep 21, 2017
| - window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel); | ||
| - window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET); | ||
| + QString WalletName = QString::fromStdString(pwallet->GetName()); | ||
| + if (WalletName.endsWith(".dat")) { |
| @@ -462,6 +462,15 @@ void BitcoinGUI::createToolBars() | ||
| toolbar->addAction(receiveCoinsAction); | ||
| toolbar->addAction(historyAction); | ||
| overviewAction->setChecked(true); | ||
| + | ||
| +#ifdef ENABLE_WALLET |
|
Nice! Conceptual issues:
Ideas:
Code:
|
promag
referenced this pull request
Sep 25, 2017
Open
[wallet] Use shared pointer for wallet instances #11402
|
I think we can fairly easily pull out the contentious rpcauth parts of this to make it more palatable for review. I have a branch here: https://github.com/jnewbery/bitcoin/tree/pr11383.1 which removes the first three commits and makes the one change to |
|
Rebased, eliminated I did not address @jonasschnelli's GUI comments, because I feel some is best explored separately, as improvements on top of this, while others (confirming wallet changes with a prompt) I think would make the feature annoying to use. |
| @@ -252,7 +252,7 @@ public Q_SLOTS: | ||
| QTimer *pollShutdownTimer; | ||
| #ifdef ENABLE_WALLET | ||
| PaymentServer* paymentServer; | ||
| - WalletModel *walletModel; | ||
| + std::vector<WalletModel*> walletModels; |
ryanofsky
Oct 9, 2017
Contributor
In commit "Qt: Load all wallets into WalletModels"
Might be simpler to make this a vector of unique_ptr, to avoid need for manual deletions. Also since renaming this member anyway, could follow current naming convenetion (m_wallet_models).
| + const int wallet_index = ui->WalletSelector->currentIndex(); | ||
| + if (wallet_index > 0) { | ||
| + CWalletRef *ppwallet = (CWalletRef*)ui->WalletSelector->itemData(wallet_index).value<void*>(); | ||
| + ppwallet = new CWalletRef(*ppwallet); // Refcount |
ryanofsky
Oct 9, 2017
Contributor
In commit "Qt: Add wallet selector to debug console"
What does refcount comment mean? Is this a todo suggesting that you want to add refcounting in the future? Should clarify comment or maybe remove it.
| @@ -65,6 +65,15 @@ WalletModel::~WalletModel() | ||
| unsubscribeFromCoreSignals(); | ||
| } | ||
| +QString WalletModel::getWalletName() const |
ryanofsky
Oct 9, 2017
Contributor
In commit "Qt: When multiple wallets are used, include in notifications the name"
Would be nice to follow this up by removing the name parameter passed to BitcoinGUI::addWallet to avoid duplicating .dat stripping logic.
| @@ -95,13 +95,13 @@ void WalletView::setBitcoinGUI(BitcoinGUI *gui) | ||
| connect(this, SIGNAL(message(QString,QString,unsigned int)), gui, SLOT(message(QString,QString,unsigned int))); | ||
| // Pass through encryption status changed signals | ||
| - connect(this, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(setEncryptionStatus(int))); | ||
| + connect(this, SIGNAL(encryptionStatusChanged(int)), gui, SLOT(updateWalletStatus())); |
ryanofsky
Oct 9, 2017
Contributor
In commit "Qt: Ensure UI updates only come from the currently selected walletView"
This is silently dropping the int status value passed to encryptionStatusChanged, and the int hdEnabled value passed to hdEnabledStatusChanged. Assuming this is intended, you should clean up after this change by deleting the unused parameters from encryptionStatusChanged and hdEnabledStatusChanged declarations and calls.
| -static const std::string WALLET_ENDPOINT_BASE = "/wallet/"; | ||
| - | ||
| -CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest& request) | ||
| +void JSONRPCRequestWalletResolver(JSONRPCRequest& jreq, const HTTPRequest& httpreq) |
ryanofsky
Oct 9, 2017
Contributor
In commit "RPC: Pass wallet through JSONRPCRequest"
Multiwallet rpc calls are broken in this commit (and the whole PR) because JSONRPCRequestWalletResolver is not actually registered or called anywhere. Maybe a commit was lost in the rebase? The problem causes multiwallet.py test to fail with "Wallet file not specified"
|
(Note Travis failure is due to the batch request bug fixed in #11277) |
|
#11277 is merged. Can you rebase? |
|
Rebased |
fanquake
added this to In progress
in Multiwallet support
Nov 4, 2017
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Nov 6, 2017
added a commit
to bitcoinknots/bitcoin
that referenced
this pull request
Nov 6, 2017
laanwj
added this to Blockers
in High-priority for review
Nov 16, 2017
luke-jr
added some commits
Sep 9, 2016
jonasschnelli
approved these changes
Nov 16, 2017
Lightly tested ACK: 555eec1
Works as intended.
Visually not very elegant, but an acceptable first step.
| /** WWW-Authenticate to present with 401 Unauthorized response */ | ||
| static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\""; | ||
| +boost::signals2::signal<void (JSONRPCRequest&, const HTTPRequest&)> PrepareJSONRPCRequestCallbacks; |
jonasschnelli
Nov 16, 2017
Member
Isn't the HTTPRequest object unused? Why pack it into the signal, future extensions?
| + PrepareJSONRPCRequestCallbacks.connect(preparer); | ||
| +} | ||
| + | ||
| +void UnregisterJSONRPCRequestPreparer(const JSONRPCRequestPreparer& preparer) |
| @@ -236,6 +251,9 @@ bool StartHTTPRPC() | ||
| #ifdef ENABLE_WALLET | ||
| // ifdef can be removed once we switch to better endpoint support and API versioning | ||
| RegisterHTTPHandler("/wallet/", false, HTTPReq_JSONRPC); | ||
| + | ||
| + void JSONRPCRequestWalletResolver(JSONRPCRequest& jreq, const HTTPRequest& httpreq); |
| - // in Qt, use always the wallet with index 0 when running with multiple wallets | ||
| - QByteArray encodedName = QUrl::toPercentEncoding(QString::fromStdString(vpwallets[0]->GetName())); | ||
| - req.URI = "/wallet/"+std::string(encodedName.constData(), encodedName.length()); | ||
| + CWalletRef * const ppwallet = (CWalletRef*)ppwallet_v; |
jonasschnelli
Nov 16, 2017
Member
looks like we should use a C++11 (shared?) pointer here to avoid the manual memory management.
promag
reviewed
Nov 19, 2017
•
Tested, but will look the code. Works as expected.
There are some style issues that could be addressed here or in follow ups:
- combo and label in the toolbar use different style (font for instance) than the buttons;
- not sure if the right side is the best place in terms of UX;
- maybe it should be possible to select wallet from the menu bar (for instance, File -> Wallets -> w1);
- window titles could have the wallet name too;
- the combo in the console is a bit lost (this time is not in a toolbar);
- could show a message in the console when the wallet is changed.
| @@ -45,8 +47,9 @@ class JSONRPCRequest | ||
| bool fHelp; | ||
| std::string URI; | ||
| std::string authUser; | ||
| + CWallet *wallet; |
|
I tested the debug console by switching wallets (including no wallet) and using I agree with @promag's suggestions and added a few below. I don't think any should block this PR, although some might simplify it. Maybe this is what you were saying, but I have a light preference for reducing UI clutter by removing the dropdowns and instead adding Wallet to the primary menu (between File and Settings). The application title would contain the name of the currently selected wallet, as you suggested. In the Wallet menu, the selected wallet would have a check box, and not be selectable. This has a couple of advantages:
I assume #10740 is needed before wallets can be added through the UI? I like @jonasschnelli's suggestion of allowing each wallet to have a name, so the file name can be inconspicuous. Same for clearly showing the wallet name on the send confirmation screen. I also like the idea of using color, although that can get ugly very quickly. In case anyone else was confused like me, this how you launch with multiple wallets: |
Sjors
referenced this pull request
Nov 20, 2017
Open
[wallet] dynamic loading/unloading of wallets #10740
| + | ||
| +bool BitcoinGUI::multiWallet() const | ||
| +{ | ||
| + return (WalletSelector->count() > 1); |
Sjors
Nov 22, 2017
Contributor
Using a UI element to count the number of wallets doesn't seem ideal.
luke-jr commentedSep 21, 2017
•
Edited 1 time
-
luke-jr
Oct 6, 2017
This adds a combobox to the GUI main window and debug window to select the wallet being viewed/used.