-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Add importmulti RPC call #7551
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
Add importmulti RPC call #7551
Conversation
|
Concept ACK |
src/wallet/rpcdump.cpp
Outdated
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.
@laanwj should we catch specific exceptions to return the error?
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.
IMO should catch the JSONRPCError and be included on the response, something like:
output: [
{
"result": true
},
{
"result": false,
"error": {
"code": -5,
"message": "Invalid Bitcoin address"
}
}
]and catch other exceptions as "missing required fields" (runtime_error). Also maybe changing from "result" to "success".
|
concept ACK I have implemented a method to also simply just import an spv proof + transaction rather than rescan. Would be nice to include that in this as well. (need to add tests and PR...) |
4f9bbbf to
3f2e87e
Compare
|
Concept ACK. |
qa/rpc-tests/importmulti.py
Outdated
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.
This is never used?
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.
True, i will remove.
3f2e87e to
182bcc2
Compare
I agree. Though I've done a similar thing in #7552. Use positional arguments only for the 'essential' arguments, and an associative array for everything optional or future-extensible. Much less hassle and confusing than APIs with tons of positional arguments, especially optional ones. |
|
@jonasschnelli there is also #7518 that accepts options as a JSON object. |
|
GBT also uses an options Object |
Github-Pull: bitcoin#7551 Rebased-From: 182bcc26d71dd8d25058d06c8c144cfebb8ec2e3
|
concept ACK |
182bcc2 to
795adf4
Compare
|
Replaced the output result from [ { "result": true } , ... ] to [ { "success": true } , ... ]. In case of giving a exception should we show any information of the reason in the result? Something like: |
|
Passing along error messages would be hugely helpful, yes. |
|
Another thing, currently we match the input to the output status by the order given of the input array. Example: input = [ { type: "address", value: "myaddress1"}, { type: "address", value: "myaddress2"}, ... ] to something like: input = [ { type: "address", value: "myaddress1"}, { type: "address", value: "myaddress2"}, ... ] Or maybe include in the reference the complete input node . In this case when the user calls the importmulti it can pass any type of extra information that later can be useful to take some action. |
|
I'll have to defer to others on the value of that. I don't see much value-add personally but unsure. |
4719852 to
960f086
Compare
qa/rpc-tests/importmulti.py
Outdated
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: only need to initialize 2 nodes
e4d03e7 to
215caba
Compare
|
Rebased. |
|
Re-Tested ACK 215caba |
Yes, agreed. The code is self-contained so the risk of regressions is minimal. The |
Github-Pull: bitcoin#7551 Rebased-From: cb08fdb
Github-Pull: bitcoin#7551 Rebased-From: 215caba
|
bisect identifies cb08fdb as the commit that causes the compile to fail with:- I am confused as to how this tested ok and got merged when it doesn't compile.. |
| CPubKey pubkey = key.GetPubKey(); | ||
| assert(key.VerifyPubKey(pubkey)); | ||
|
|
||
| CKeyID vchAddress = pubkey.GetID(); |
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.
pubKey is not defined.... pubkey is though!
|
This has not given any compile issues for anyone else besides a boost issue which was fixed later ( #8980). If you are trying to merge this into some other code base do not complain here if the build breaks. |
Zcash: Excludes changes to importwallet (missing bitcoin/bitcoin#11667) and ProcessImport (missing bitcoin/bitcoin#7551).
Bitcoin wallet PRs 3 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#7687 - bitcoin/bitcoin#11116 - Excludes SegWit tests - Excludes `isInvalid` code (which is part of the SegWit support structure) - bitcoin/bitcoin#13002 - Excludes changes to `importwallet` (missing bitcoin/bitcoin#11667) - Excludes changes to `ProcessImport` (missing bitcoin/bitcoin#7551) - Third commit was rewritten to add an internal SigVersion argument (which we didn't have because it was added to support SegWit logic).
7e0c709 Clean up importmulti help text (Fuzzbawls) 1cacda6 [Tests] Fix and Re-enable wallet_importmulti.py (random-zebra) 4ff0b4a [Trivial] NULL --> nullptr in skiplist_tests (random-zebra) b53a986 Add unit test for FindEarliestAtLeast (Suhas Daftuar) d1bb973 [RPC] Add importmulti call (random-zebra) Pull request description: Based on top of: - [x] #2240 Essentially backport bitcoin#7551 and bitcoin#9490, with more recent changes to adapt to the current sources. Fix and re-enable the `wallet_importmulti.py` functional test. ACKs for top commit: Fuzzbawls: ACK 7e0c709 furszy: ACK 7e0c709 and merging.. Tree-SHA512: 47a4452bfaeae16d09268d3eaa0c1a5d94a39accf86b7345818f8436222650515a8bf66ef331ba478058aabcbcfcf978192f39b349027e189b7ac41cd3e69a6e
As discussed in PR #6570 this is a new rpc call
importmultithat receives an array of JSON objects representing the intention of importing a public key, a private key, an address and script/p2sh:and rescans (if not disabled in second argument) the chain from the block that has a timestamp lowest than the lowest timestamp found in all requests, preventing scanning from genesis.
The output is an array with the status of each request:
Arguments:
Some notes:
Edit: As suggested by @promag i've replaced the second argument (optional)
boolto JSON to be easier specify new options and added a newtype="script"to support only script values, so cantype="address"work only with addresses.