-
Notifications
You must be signed in to change notification settings - Fork 38.8k
rpc/wallet: add optional transaction(s) to getbalances #22776
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
Conversation
127e3bd to
92fe092
Compare
|
Concept ACK. Will try today. |
92fe092 to
1a1fef9
Compare
|
Approach ACK, definitely prefer this over #22751 👍 |
|
How is the user going to use this? Call the RPC thrice and compare the results?
|
|
@MarcoFalke The transaction is supposedly not yet broadcasted. They'd only need to call getbalances once. The existing output would give the wallet's balance as it is (excluding the transaction), and the added "changes" would show how the balance would change, if the transaction was broadcasted. I.e. I get a coin-join with 100 other inputs and a bunch of outputs. I call |
|
Oh I didn't see the changed result, because the documentation wasn't updated. |
1a1fef9 to
67ff5ae
Compare
|
Good point, documentation updated. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
ghost
left a comment
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.
tACK 67ff5ae
Tested with different transactions (input from wallet, input not belonging to wallet, outputs from wallet, outputs outside wallet)
Example:
Request:
POST /wallet/W2 HTTP/1.1
Host: 127.0.0.1:18333
Authorization: Basic dXNlcjMzOnBhc3N3b3JkMzM=
Content-Type: text/plain
Content-Length: 521
{"jsonrpc": "1.0", "id": "curltest", "method": "getbalances", "params": ["02000000000101fff8d9d39105eeec162fb45bd2a3e796b255866469a2cc7de93e438f3722c1490000000000fdffffff02801a0600000000001600145b497cfd64324fb0c4f7317472ca591cd7eb3bbfe093040000000000160014b1348ec3acd422b7c84f97f8757a0a5c3db9e32d02473044022020c3a9d7d06429008de82f13de672aac7886c5d6557a7c330bcb8cbc20b8cf4f02203890042ed8bf331e92f07df5d2a7bf5d8ade12cbb216f14493a98d0a188c4918012103c65a6e4a66a4a6b4af981c5e81632bb2d7336bc75d7ccf83e055006a2693050f00000000"]}
Response:
{
"result": {
"mine": {
"trusted": 5051.31588006,
"untrusted_pending": 0.00000000,
"immature": 0.00000000
},
"tx": {
"changes": 0.00000000
}
},
"error": null,
"id": "curltest"
}
Everything looks good to me. Also tested by fuzzing this argument for getbalances with random strings. No issues.
|
-0 on this. As I commented in #22751 (comment), I would prefer a broader "see how transactions modify the wallet without actually modifying it" RPC rather than trying to jam that functionality into an existing one. But if this is the approach that others prefer, then I would also prefer this to accept multiple transactions (as an array) rather than a single transaction. It is conceivable that a user would want to see how multiple transactions would modify their wallet at the same time, e.g. when broadcasting a package. |
67ff5ae to
d14266d
Compare
|
Switched to array of raw transactions. I am neutral on whether to add this here or create a new simulaterawtransaction as in #22751. |
d14266d to
2c4e77e
Compare
|
#22751 seems to make more sense IMO If users need both pieces of information, they can just batch them. |
src/wallet/rpcwallet.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.
It seems weird to have an array of raw transactions as a positional argument here.
|
I think #22751 is emerging as the superior option here. Ping if you disagree and I'll reopen this. |
|
Some prefer this over #22751, so reopening this for now. |
2c4e77e to
f7c4f88
Compare
One or several optional transactions provided to getbalances iterates over the inputs and outputs, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally.
f7c4f88 to
e63ec4c
Compare
I tend to agree here. It is useful functionality but I think it's cleaner to have it separated as a seperate RPC. |
|
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
db10cf8 rpc/wallet: add simulaterawtransaction RPC (Karl-Johan Alm) 701a64f test: add support for Decimal to assert_approx (Karl-Johan Alm) Pull request description: (note: this was originally titled "add analyzerawtransaction RPC") This command iterates over the inputs and outputs of the given transactions, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally. I originally proposed this to Elements (ElementsProject/elements#1016) and it was suggested that I propose this upstream. There is an alternative #22776 to instead add this info to `getbalances` when providing an optional transaction as argument. ACKs for top commit: jonatack: ACK db10cf8 achow101: re-ACK db10cf8 Tree-SHA512: adf222ec7dcdc068d007ae6f465dbc35b692dc7bb2db337be25340ad0c2f9c64cfab4124df23400995c700f41c83c29a2c34812121782c26063b100c7969b89d
db10cf8 rpc/wallet: add simulaterawtransaction RPC (Karl-Johan Alm) 701a64f test: add support for Decimal to assert_approx (Karl-Johan Alm) Pull request description: (note: this was originally titled "add analyzerawtransaction RPC") This command iterates over the inputs and outputs of the given transactions, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally. I originally proposed this to Elements (ElementsProject/elements#1016) and it was suggested that I propose this upstream. There is an alternative bitcoin#22776 to instead add this info to `getbalances` when providing an optional transaction as argument. ACKs for top commit: jonatack: ACK db10cf8 achow101: re-ACK db10cf8 Tree-SHA512: adf222ec7dcdc068d007ae6f465dbc35b692dc7bb2db337be25340ad0c2f9c64cfab4124df23400995c700f41c83c29a2c34812121782c26063b100c7969b89d
Optional transactions provided to getbalances iterates over the inputs and outputs, and tallies up the balance change for the given wallet. This can be useful e.g. when verifying that a coin join like transaction doesn't contain unexpected inputs that the wallet will then sign for unintentionally.
This is an alternative to #22751.