-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Multiwallet: simplest endpoint support #10849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiwallet: simplest endpoint support #10849
Conversation
Looks good to me too, utACK c8115e3. |
This has no documentation. If we think this approach is a good idea, I would like to see in what way it can be explained to users. Is there going to be a Also, from the other issue I think something like And, also from other issue I think ' |
Definitely no! Let's not repeat this: JSON-RPC uses POST only, and with POST it is weird to have |
Don't know your source for this but this is done all the time.
I don't know why it wouldn't be true. I can think of lots of RPC options you might want to add outside the RPC request: timeouts, completions handlers, etc.
Not true, you don't have to ignore any option, but it is good practice to accept options in any order. This is one of the reasons people choose to used named options instead of positional arguments. |
Those really shouldn't be passed in the URL. The URL locates something, such as the wallet in this case. |
They shouldn't be part of the uri-path, but you would have to explain more why they shouldn't be options in a query string... |
ryanofsky: Among other reasons the path approach will already work with most but not all software, e.g. you change your RPC endpoint url to be one with the path, and tada-- done, no source code modifications in some things. I believe a query string would not achieve this, and in some cases require deep spelunking. I could see an argument that something like a timeout might make sense as a query like parameter, but a wallet seems like a pretty perfect 'navigation' like element. |
And yes, there should be. Documentation is good. |
This is true for this PR but not #10650 which is a big reason why I think this PR is better and less user-hostile than #10650. @laanwj, my bigger point is about extensibility . We want to add a wallet option right now. Great, so that can be as simple as adding If we use paths instead, are we requiring I guess another thing that is motivating me is that I would like to see less uri-path space annexed for this one multiwallet feature. Right now json-rpc calls go directly to Also, so my other points doesn't get lost above, it would be great to see something done on documentation and |
It's under /wallet/ at least, so I think it won't have any clashes with other use. As far as usewallet-- I think we intend that argument to eventually specify all wallets that get loaded, not just specific to rpc. e.g. it would also tell it which ones to load in the UI when that support is complete. |
I could easily imagine a web interface wanting to handle /wallet path. The point is that if RPCs are restricted to exactly one path
That's interesting. I thought the UI was would just have tabs or a dropdown to choose between any of the loaded wallets. But I guess the advantage of having the |
src/bitcoin-cli.cpp
Outdated
@@ -241,7 +242,20 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) | |||
assert(output_buffer); | |||
evbuffer_add(output_buffer, strRequest.data(), strRequest.size()); | |||
|
|||
int r = evhttp_make_request(evcon.get(), req.get(), EVHTTP_REQ_POST, "/"); | |||
// check if we should use a special wallet endpoint | |||
std::string endpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bug: if no wallet is specified then the endpoint will be "" instead of "/"
result: bitcoin-cli doesn't work without a -usewallet
parameter:
→ bitcoin-cli getinfo
error: no response from server
Fix is:
std::string endpoint = "/";
It's a shame that this PR doesn't prevent individual wallet endpoints from accessing server-level RPCs. However that can be added at a later date. I have a branch here: https://github.com/jnewbery/bitcoin/tree/pr10849 that does a couple of things:
Feel free to squash the first commit and cherry-pick the next two if you think they're useful. |
c8115e3
to
6b9faf7
Compare
Force push fixed the endpoint issue (thanks @jnewbery). Fixes can be done later. |
Agree. Multiwallet interface should be considered unstable for v0.15. |
So this will remove the concept of "default wallet" from the RPCs? Any attempt to use a wallet RPC without specifying a wallet will fail, right? |
@achow101: only if you call a wallet RPC and if you run with multiple wallets. |
@jonasschnelli Ok, cool! utACK 6b9faf7 |
super().__init__() | ||
self.setup_clean_chain = True | ||
self.num_nodes = 1 | ||
self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you change one of these to just 'w' to catch possible length extension bugs? If we're asking for w2, we want to make sure that we don't get w. on accident.
Code review utACK 6b9faf7. No opinion on the endpoint discussion. |
This is incompatible with RPC batching. :( (you can't batch a /wallets/ request with one which does not use it) |
Ok disregard my comment. I thought that adding /wallet/w1 to a non wallet RPC method would fail. This is not the case, so no issue! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post-merge utACK 6b9faf7
walletinfo = w1.getwalletinfo() | ||
assert_equal(walletinfo['immature_balance'], 50) | ||
|
||
#check w1 wallet balance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: w2
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes #10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
Summary: Merge #11743: qa: Add multiwallet prefix test fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin/bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1 Core PR11743 Fixes T177 Test Plan: ./test/functional/test_runner.py multiwallet Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: teamcity Maniphest Tasks: T177 Differential Revision: https://reviews.bitcoinabc.org/D1055
ZIP 32 preparations Includes Makefile changes cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7689 - bitcoin/bitcoin#10849 Part of #3380.
6b9faf7 [QA] add basic multiwallet test (Jonas Schnelli) 979d0b8 [tests] [wallet] Add wallet endpoint support to authproxy (John Newbery) 76603b1 Select wallet based on the given endpoint (Jonas Schnelli) 32c9710 Fix test_bitcoin circular dependency issue (Jonas Schnelli) 31e0720 Add wallet endpoint support to bitcoin-cli (-usewallet) (Jonas Schnelli) dd2185c Register wallet endpoint (Jonas Schnelli) Pull request description: Alternative for bitcoin#10829 and bitcoin#10650. It adds the most simplest form of wallet based endpoint support (`/wallet/<filename>`). No v1 and no node/wallet endpoint split. Tree-SHA512: 23de1fd2f9b48d94682928b582fb6909e16ca507c2ee19e1f989d5a4f3aa706194c4b1fe8854d1d79ba531b7092434239776cae1ae715ff536e829424f59f9be
6b9faf7 [QA] add basic multiwallet test (Jonas Schnelli) 979d0b8 [tests] [wallet] Add wallet endpoint support to authproxy (John Newbery) 76603b1 Select wallet based on the given endpoint (Jonas Schnelli) 32c9710 Fix test_bitcoin circular dependency issue (Jonas Schnelli) 31e0720 Add wallet endpoint support to bitcoin-cli (-usewallet) (Jonas Schnelli) dd2185c Register wallet endpoint (Jonas Schnelli) Pull request description: Alternative for bitcoin#10829 and bitcoin#10650. It adds the most simplest form of wallet based endpoint support (`/wallet/<filename>`). No v1 and no node/wallet endpoint split. Tree-SHA512: 23de1fd2f9b48d94682928b582fb6909e16ca507c2ee19e1f989d5a4f3aa706194c4b1fe8854d1d79ba531b7092434239776cae1ae715ff536e829424f59f9be
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
6b9faf7 [QA] add basic multiwallet test (Jonas Schnelli) 979d0b8 [tests] [wallet] Add wallet endpoint support to authproxy (John Newbery) 76603b1 Select wallet based on the given endpoint (Jonas Schnelli) 32c9710 Fix test_bitcoin circular dependency issue (Jonas Schnelli) 31e0720 Add wallet endpoint support to bitcoin-cli (-usewallet) (Jonas Schnelli) dd2185c Register wallet endpoint (Jonas Schnelli) Pull request description: Alternative for bitcoin#10829 and bitcoin#10650. It adds the most simplest form of wallet based endpoint support (`/wallet/<filename>`). No v1 and no node/wallet endpoint split. Tree-SHA512: 23de1fd2f9b48d94682928b582fb6909e16ca507c2ee19e1f989d5a4f3aa706194c4b1fe8854d1d79ba531b7092434239776cae1ae715ff536e829424f59f9be
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
d5526bd Wrap dumpwallet warning and note scripts aren't dumped (MeshCollider) 3711c6a Add wallet backup text to import*, add* and dumpwallet RPCs (MeshCollider) dbda874 [Wallet] always show help-line of wallet encryption calls (Jonas Schnelli) 20c269b Avoid opening copied wallet databases simultaneously (Russell Yanofsky) e411b70 [wallet] Fix leak in CDB constructor (João Barbosa) f15aeea Change getmininginfo errors field to warnings (Andrew Chow) c04390b Unify help text for GetWarnings output in get*info RPCs (random-zebra) 1d966ce Add warnings field to getblockchaininfo (Andrew Chow) ffcd781 [Trivial] Cleanup after MOVE-ONLY commits (random-zebra) e067235 MOVEONLY: Init functions wallet/wallet.cpp -> wallet/init.cpp (random-zebra) e947eec MOVEONLY: Fee functions wallet/wallet.cpp -> wallet/fees.cpp (random-zebra) 2188c3e Move some static functions out of wallet.h/cpp (random-zebra) f49acf7 [wallet] [moveonly] Move CAffectedKeysVisitor (random-zebra) 8bd979f [wallet] Specify wallet name in wallet loading errors (random-zebra) 900bbfa Reject invalid wallet files (João Barbosa) a1f4e2a Reject duplicate wallet filenames (random-zebra) ee52c2e Fix misleading "Method not found" multiwallet errors (Russell Yanofsky) ce35e1e [Qt] Use wallet 0 in rpc console if running with multiple wallets (random-zebra) 37089d1 [tests] Update wallet_multiwallet.py functional test (random-zebra) 3955ee9 [Doc] Update release notes (random-zebra) 4fd5913 [wallet] [rpc] Add listwallets RPC (John Newbery) 1525281 [wallet] [rpc] print wallet name in getwalletinfo (John Newbery) fdf5da0 [wallet] fix comment for CWallet::Verify() (John Newbery) cf4a90b Remove factor of 3 from definition of dust. (random-zebra) a1c56fd [Policy] Introduce -dustrelayfee (random-zebra) 9fb29cc [Doc] Update multiwallet release notes (random-zebra) 379255e [Tests][Trivial] Add wallet_multiwallet.py to test_runner (random-zebra) 808fbc3 [Bugfix] consider boolean value of -zapwallettxes ParameterInteraction (random-zebra) f9141f8 [QA] Add wallet_multiwallet.py functional test (John Newbery) 2e02006 Rename -usewallet to -rpcwallet (Alex Morcos) a64440b Select wallet based on the given endpoint (Jonas Schnelli) 5683a9c Complete previous commit by moving mn stuff out of libbitcoin_wallet (random-zebra) b0fe92f Fix test_pivx circular dependency issue (random-zebra) 6cb2b92 Add wallet endpoint support to bitcoin-cli (-usewallet) (Jonas Schnelli) 7dd3916 Register wallet endpoint (Jonas Schnelli) 5bd1bd7 Properly forbid -salvagewallet and -zapwallettxes for multi wallet. (Alex Morcos) 41a7335 Remove unused variables (practicalswift) 5c3d73f Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings (Russell Yanofsky) e7cafab [Refactoring] Mimic ListCoins for sapling notes (random-zebra) 54fa122 [qt] Move some WalletModel functions into CWallet (random-zebra) 494ba64 [test] Add test for getmemoryinfo (random-zebra) 2394083 [Wallet] unset change position when there is no change on exact match (Gregory Sanders) 7d977ac Remove unused C++ code not covered by unit tests (random-zebra) 60bb4da ApproximateBestSubset should take inputs by reference, not value (Ryan Havar) 3633d75 Initialize nRelockTime (Patrick Strateman) 3a599d0 [Refactor] Return safeTx boolean in CheckTXAvailability (random-zebra) f219be9 Add safe flag to listunspent result (NicolasDorier) 0201065 Add COutput::fSafe member for safe handling of unconfirmed outputs (random-zebra) 75c8c6d Disallow copy of CReserveKeys (Gregory Sanders) 8378322 [Refactor] Replace optional reserveKey in PBF with unique pointer (random-zebra) Pull request description: I think these are all the remaining Bitcoin Core v0.15 PRs in the wallet area that we don't have yet, and are useful to us. I've grouped them here since they are all pretty small, simple, and narrow-focused (on the wallet/rpcwallet files). This changeset is based on top of - [x] #2337 as it keeps going with the multiwallet implementation, adding: - RPC endpoint support - `listwallets` RPC - wallet name in `getwalletinfo` RPC - `wallet_multiwallet.py` functional test As in some areas we are much closer to upstream, some of the commits needed adaptations (especially the functional tests). A couple of commits have been extended to include shield-related code. List of upstream PRs backported/adapted: - bitcoin#9906 : Disallow copy constructor CReserveKeys - bitcoin#9830 : Add safe flag to listunspent result - bitcoin#9993 : Initialize nRelockTime - bitcoin#10108 : ApproximateBestSubset should take inputs by reference, not value - bitcoin#10075 : Remove unused C++ code not covered by unit tests - bitcoin#10257 : Add test for getmemoryinfo - bitcoin#10295 : Move some WalletModel functions into CWallet - bitcoin#10500 : Avoid CWalletTx copies in GetAddressBalances and GetAddressGroupings - bitcoin#10522 : Remove unused variables - bitcoin#10816 : Properly forbid -salvagewallet and -zapwallettxes for multi wallet - bitcoin#10849 : Multiwallet: simplest endpoint support - bitcoin#9380 : Separate different uses of minimum fees (only dustRelayFee) - bitcoin#10817 : Redefine Dust and add a discard_rate (only first commit) - bitcoin#10883 : Rename -usewallet to -rpcwallet - bitcoin#10604 : Add listwallets RPC, include wallet name in getwalletinfo + tests - bitcoin#10893 : Avoid running multiwallet.py twice - bitcoin#10870 : Use wallet 0 in rpc console if running with multiple wallets - bitcoin#10931 : Fix misleading "method not found" multiwallet errors - bitcoin#10885 : Reject invalid wallets - bitcoin#11022 : Basic keypool topup - bitcoin#10976 : [MOVEONLY] Move some static functions out of wallet.h/cpp - bitcoin#11310 : Test listwallets RPC - bitcoin#10858 : "errors" to getblockchaininfo + unify "errors" field in get*info RPCs - bitcoin#11492 : Fix leak in CDB constructor - bitcoin#11476 : Avoid opening copied wallet databases simultaneously - bitcoin#11590 : always show help-line of wallet encryption calls - bitcoin#11289 : Add wallet backup text to import* and add* RPCs ACKs for top commit: furszy: re-re-utACK d5526bd. Fuzzbawls: ACK d5526bd Tree-SHA512: 115c4916ee212539b0a1b2cb25783ddf6753f5376de739a084191e874ed8717fff2c7cd9d744e397891f14eaa459ef2f48d675168621ef7316e81758fa6559f2
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
fa61c6f6a qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin/bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
fa61c6f qa: Add multiwallet prefix test (MarcoFalke) Pull request description: Fixes bitcoin#10849 (comment) Tree-SHA512: 7967be04e76d935398b3bea60c864ffc9e38dbb4cfb55890bb146a6f16c28d81ca5d89736275e2d0b03642806f6f7093beeea979f5257c464f437c4e5a9684f1
Alternative for #10829 and #10650.
It adds the most simplest form of wallet based endpoint support (
/wallet/<filename>
).No v1 and no node/wallet endpoint split.