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
[RPC] Add bumpfee command. #7865
Conversation
d1429d6
to
f68447a
Compare
@@ -533,6 +533,11 @@ class CAccountingEntry | |||
std::vector<char> _ssExtra; | |||
}; | |||
|
|||
enum CreateTransactionFlags { | |||
CREATE_TX_DEFAULT = 0, |
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 to me default is simply "not bip125". Not sure the name "default" really fits, especially longer-term.
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.
I think the CREATE_TX_DEFAULT
is okay. Passing just a 0
(int) would require casting. "not bip125" is also not true because in future you could combine flags (Don't SIGN & RBF)?
f68447a
to
45b6ec5
Compare
Force push fixed @instagibbs nits. |
utACK post-nits Although it might make sense to split this into ~3 PRs to get through a couple faster, and each of which would still be useful on their own:
|
CReserveKey reservekey(pwalletMain); | ||
if(!pwalletMain->FundTransaction(tx, reservekey, nFee, nChangePos, strFailReason, false)) | ||
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason); | ||
|
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.
Why not ensuring (nFee - nOldFee) > minTxRelayFee
, and if not, exit early with a descriptive JSONRpcError which say the fees are high enough and can't be bumped ?
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.
Yes. I have though about that. But you also would like to have a check that makes sure, it would be accepted as replacement.
This would require to factor out the RBF check from main.cpp
to rbf.cpp
(which probably would sense in a follow up PR).
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.
Yes, but CommitTransaction later is already doing that under the hood if I understand.
The most likely problem is that the fees can't be bumped, for the 0.0001% chance that it still get rejected for whatever other issue during the CommitTransaction, a generic error message would be enough.
@jonasschnelli Can you please separate "Bitcoin-Tx / CreateRawTransaction" changes into new PR, so this can get merged? |
@jonasschnelli maybe unrelated to this PR, or I should bring that up in a meeting (sadly it is 4am in japan when there is core meeting), but I think a better (or alternative) bumpfee would be one which take the number of block to confirm. As a developer using the RPC API, I'd like my backend to bump fees periodically to reach confirmation target in case of fee increase. So that bumpfee 3 would mean "put whatever fee at current rate that can confirm into 3 blocks". If the calculated fee are smaller than current one, then it would do be a no op. It might not belong to this PR though. It would also be used if I initially said "confirm into 20 blocks", then changed my mind and say "now I want to confirm in the next block". |
@NicolasDorier: I agree that a confirm target for the This PR is already relatively large, we should probably add this feature in another PR. |
right, utACK |
45b6ec5
to
32d3666
Compare
Rebased (non trivial after #7518). |
7dc957d
to
395571b
Compare
Removed |
395571b
to
5a4cb5e
Compare
Needed rebase. |
@@ -0,0 +1,85 @@ | |||
#!/usr/bin/env python2 |
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.
Mind to change this to py3?
replacedTx= self.nodes[1].getrawtransaction(rbftx) | ||
assert(False) | ||
except JSONRPCException as e: | ||
assert_equal(len(replacedTx), 0) |
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.
Is this doing anything different that assert_raises(JSONRPCException, ...
?
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.
Right. Fixed.
84085d1
to
9569bb0
Compare
9569bb0
to
e9931f5
Compare
Rebased. Fixed nit reported by @MarcoFalke. |
@@ -745,8 +749,13 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface | |||
* selected by SelectCoins(); Also create the change output, when needed | |||
* @note passing nChangePosInOut as -1 will result in setting a random position | |||
*/ | |||
<<<<<<< 08b37c5e06bf1698c1d0e5905806382cbfa8cefd |
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.
Unresolved conflict
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.
Oh. Messed up the rebase. Will fix.
Wait: you commented and old commit.
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.
@jonasschnelli This commit is still in the history.
You didn't solve the conflict in this commit but in a later one. Looks weird if someone digs through it.
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.
e9931f5
to
c3b60c8
Compare
This will allow to add flags for RBF and other features
c3b60c8
to
4bbf2cf
Compare
Rebased and improved. Now the bumpfee command takes an existing |
nonrbftx = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 1, "", "", True, False) | ||
|
||
try: | ||
bumpedrawtx = self.nodes[0].bumpfee(nonrbftx) |
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.
Replace by
assert_raises(JSONRPCException, self.nodes[0].bumpfee, nonrbftx)
Mind to squash the history to aid review? |
hmm, "Currently, bumpfee will increase the fees by using the not sure if I'm missing something but when I think I read the code right and you just need to update your initial description of the PR, in which case; utACK as said before by others, I think also nits; remove |
it = tx.vout.erase(it); | ||
} | ||
else { | ||
++it; |
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.
I think this increment needs to happen always, even if the condition above is true.
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.
doesn't tx.vout.erase(it);
result in pointing to the next element in the iteration?
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.
erase returns the new position of the next element after the one that is erased, so it = tx.vout.erase(it)
does the right thing
Concept ACK (for future reference, I think this would have potentially been better as two PRs, with the bumpfee separate-- built on top of the first), will review. |
Is this still going into 0.13.0 ? |
@fanquake No, not as-is. Unfortunately this missed the feature freeze. At last Thursday's meeting @jonasschnelli mentioned working on much simplified minimum RPC functionality for 0.13 to serve as a stop-gap. |
superseded by #8456. Closing. |
Refactor
CreateTransaction()
now accepts a input-value over thenFee
parameter (currently only used to return the calculated fee). This "base fee" will be the delta to the calculated fee. This allows to create transaction replacements with respecting the previous fee of the replaced transaction.bumpfee RPC command
Syntax:
bumpfee <txid>
Bumpfee will directly sign&send the new transaction and reports the old/new fee and the new
<txid>
.How it works: the Bumpfee command removes all previous signatures, removes change outputs and re-funds the transaction (if necessary).
Currently,
bumpfee
will increase the fees by using the<old transaction fee> + <new transaction fee estimate>
.Increasing the fees can involve adding
n
inputs (which can again increase the require minimum fee).sendtoaddress / sandmany
Added another parameter to
sendtoaddress
andsendmany
. The boolean parameter defines if the transaction will signal opt-in-RBF over the nSequence number after BIP125.Bitcoin-Tx / CreateRawTransaction
bitcoin-tx
to accept a sequence number when adding inputscreaterawtransaction
to accept a sequence number when defining inputsPossible next steps
bumprawtransaction
command