-
Notifications
You must be signed in to change notification settings - Fork 38.6k
New outputs argument for bumpfee/psbtbumpfee
#25344
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
94a4094 to
f188181
Compare
f188181 to
814c3b2
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. 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. |
|
Concept ACK
Will the user be able to remove old outputs and add new outputs with Can you share example bitcoin-cli command with and without |
|
Without With |
|
Concept ACK |
|
@rodentrabies Thanks. I had to add double quotes in address and the commands worked. I tested the pull request by replacing a transaction on signet and add 1 output in replacement transaction: This adds another output in original transaction: It is better than nothing although I would prefer an argument that can be used to replace all outputs with new outputs. |
814c3b2 to
cbcc40b
Compare
|
ACK cbcc40b7b6eeba0e5ae195d513285b66da8d7d63 |
Maybe have one argument Let's see what the other reviewers have to say about this. Maybe it's just a bit too complex. |
Only Tx1 has A and B outputs. If user wants to add C output tin the replacement transaction Tx2: If user wants to have C and D as outputs for replacement transaction Tx2: |
What if user wants to add another A and B outputs (that is to have two A outputs and two B outputs for whatever reason)? Should the amounts be different? This "automagical" approach will quickly get confusing, I think. |
But I'm not sure we should actively support that. Addresses are only supposed to be used once, after all. |
Rather not have options that have fundamentally different behaviours/meanings based on others. |
@luke-jr agreed, that was an unfortunate example. I still think that the behavior proposed by @1440000bytes (adding new outputs if the addresses don't match and replacing outputs, if the addresses do match) is just a bit too confusing and if we end up having |
I don't like it either, just stated it for the record, I guess. |
This is exactly what I was trying to express in comments above. An argument that accepts outputs and replaces all used in original transaction. |
Ah, sorry, I for some reason assumed that you meant we add outputs C and D here (that is new transaction has A, B, C and D outputs). So bottom line: we either have EDIT: or, we can have both and make them exclusive - either use |
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.
Concept ACK
I'm curious as to the desired behavior when extra_outputs is used to add an output to the same address as an output of the original transaction. I tried doing this like so:
$ ./bitcoin-cli -regtest -rpcwallet=second_wallet getnewaddress
bcrt1q3yjd0arl7fskt5ynwm6njz4ez63p9c86yeffew
$ ./bitcoin-cli -regtest -rpcwallet=first_wallet send '{"bcrt1q3yjd0arl7fskt5ynwm6njz4ez63p9c86yeffew": 1}' null "unset" 1.1
{
"txid": "99bfd824edbff565146b9eda6f4370e851f9579c1744b0a54090dce9db6ed393",
"complete": true
}
$ ./bitcoin-cli -regtest -rpcwallet=first_wallet bumpfee "99bfd824edbff565146b9eda6f4370e851f9579c1744b0a54090dce9db6ed393" '{"extra_outputs": {"bcrt1q3yjd0arl7fskt5ynwm6njz4ez63p9c86yeffew": 30}}'
{
"txid": "07df53d9246cfdeec83646469ab1781a73814a4b3223c22d7096d812d9d66289",
"origfee": 0.00000156,
"fee": 0.00001875,
"errors": [
]
}
It appears that the transaction is fee bumped just fine and there are two outputs to the same address in the same transaction. I was wondering if this is what we want to happen or if an error should be thrown in this scenario. I think that the reason an error isn't thrown currently is because when AddOutputs is called, only extra_outputs is passed and not all of the recipients, and I think that AddOutputs is where the check for duplicate addresses takes place.
One way to deal with this, if both the extra_outputs and outputs options are added as suggested above by @rodentrabies is that in this scenario the user can be told to use outputs instead if they want to increase the amount sent to an address, which I think should avoid the creation of two outputs here.
cbcc40b to
54c924d
Compare
|
The most recent push ( |
54c924d to
8c0027e
Compare
And its easy to implement that by just removing below line from -all_outputs.insert(all_outputs.end(), wtx.tx->vout.begin(), wtx.tx->vout.end());I tested it to replace output used in Tx1 with new output in replacement transaction Tx2: Tx1: Replaced by Tx2: It could be used to cancel a transaction similar to electrum, bluewallet etc. and better for privacy in some cases. |
That and also remove the duplicate checking code in the body of the for-loop as I mentioned above - it will be redundant in that case because the duplicate check already happened in |
fbed850 to
5068940
Compare
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.
reACK 5068940
ishaanam
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.
reACK 5068940043a4c44bb9e7d3a2d70a12c753ff82e4
I also tested this by replacing the output of a transaction with external inputs.
src/wallet/rpc/spend.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.
In ab9c4225332c028a7c84260d5bf634c428698662 "wallet: extract and reuse RPC argument format definition for outputs"
for a followup: This can be used in src/rpc/rawtransaction.cpp as well as the same lines are copied for createrawtransaction and createpsbt.
src/wallet/rpc/spend.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.
This was mentioned in the RPC doc above.
However I think it is a bit confusing to have an empty array of outputs be synonymous with not providing the option at all. I think it would be better to just throw an error in that case. Checking for an empty outputs array could be done in AddOutputs as well so that check will also be done for createpsbt and createrawtransaction as it doesn't make sense to make a transaction with no outputs.
5068940 to
7e2a5c7
Compare
ff0369b to
571394a
Compare
571394a to
4c8eccc
Compare
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.
Code Review ACK 4c8eccc
|
ACK 4c8eccc |
ishaanam
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.
reACK 4c8eccc
| def spend_one_input(node, dest_address, change_size=Decimal("0.00049000"), data=None): | ||
| tx_input = dict( | ||
| sequence=MAX_BIP125_RBF_SEQUENCE, **next(u for u in node.listunspent() if u["amount"] == Decimal("0.00100000"))) | ||
| destinations = {dest_address: Decimal("0.00050000")} | ||
| if change_size > 0: | ||
| destinations[node.getrawchangeaddress()] = change_size | ||
| if data: | ||
| destinations['data'] = data |
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.
Non-blocking: This change is never used.
|
Finally. Thanks @rodentrabies this would improve UX. |


This implements a modification of the proposal in #22007: instead of adding outputs to the set of outputs in the original transaction, the outputs given by
outputsargument completely replace the outputs in the original transaction.As noted below, this makes it easier to "cancel" a transaction or to reduce the amounts in the outputs, which is not the case with the original proposal in #22007, but it seems from the discussion in this PR that the replace behavior is more desirable than add one.