-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
wallet/rpc: sendrawtransaction maxfeerate #13541
wallet/rpc: sendrawtransaction maxfeerate #13541
Conversation
718aa0b
to
43d2cce
Compare
Your PR show me actually that One could say that changing ACK. (That said, I think this would be better in |
Yes, absurdfee can actually be specified for each call to
I think having a configurable default maxtxfee would be a good idea. Perhaps this function should then ignore the default if the user does
It fits better here, because it already has the functionality needed in the |
addr = self.nodes[2].getnewaddress() | ||
txId = self.nodes[0].sendtoaddress(addr, 1.0) | ||
rawTx = self.nodes[0].getrawtransaction(txId, True) | ||
vout = False |
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.
= None
?
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.
Alternative (not tested)
vout = next(o for o in rawTx['vout'] if o['value'] == Decimal('1.00000000'))
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.
Several copies of this in rpc_rawtransaction
, so I made a dedicated commit to address the others.
src/rpc/rawtransaction.cpp
Outdated
@@ -1087,14 +1087,15 @@ UniValue signrawtransaction(const JSONRPCRequest& request) | |||
|
|||
static UniValue sendrawtransaction(const JSONRPCRequest& request) | |||
{ | |||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) | |||
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) | |||
throw std::runtime_error( | |||
"sendrawtransaction \"hexstring\" ( allowhighfees )\n" |
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.
Missing parameter.
src/rpc/rawtransaction.cpp
Outdated
size_t weight = GetTransactionWeight(*tx); | ||
CFeeRate fr(AmountFromValue(request.params[2])); | ||
CAmount max_fee = fr.GetFee((weight+3)/4); | ||
nMaxRawTxFee = nMaxRawTxFee > 0 ? std::min(nMaxRawTxFee, max_fee) : max_fee; |
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.
When specifying maxfeerate
does it make sense to pass allowhighfees=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.
I am sort of overriding allowhighfees
right now. I could disallow it completely, i.e. require that it is null or false
, if using maxfeerate
, but not sure it's worth 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.
To more directly answer your question, though, allowhighfees=true
will simply remove the existing absurd fee cap (which is 0.1 btc I believe), so if maxfeerate was really high, it actually could result in a slightly higher cap.
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.
Just have a single parameter... if it's a boolean, it's the (deprecated?) allowhighfees; if a number, then a specific limit.
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.
@luke-jr does that work with named parameters?
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.
does that work with named parameters?
Yes, it is already used by getbalance
:
bitcoin/src/wallet/rpcwallet.cpp
Line 4784 in 222e627
{ "wallet", "getbalance", &getbalance, {"account|dummy","minconf","include_watchonly"} }, |
bbb81b6
to
a43e61d
Compare
f9893d4
to
bec1abd
Compare
d562cce
to
dbd466c
Compare
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. |
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.
utACK dbd466c
src/rpc/rawtransaction.cpp
Outdated
"\nSubmits raw transaction (serialized, hex-encoded) to local node and network.\n" | ||
"\nAlso see createrawtransaction and signrawtransaction calls.\n" | ||
"\nArguments:\n" | ||
"1. \"hexstring\" (string, required) The hex string of the raw transaction)\n" | ||
"2. allowhighfees (boolean, optional, default=false) Allow high fees\n" | ||
"2. allowhighfees|maxfeerate (boolean/numeric, optional, default=false/∞) Allow high fees (boolean) or reject transactions whose fee rate is higher than the specified value (numeric), expressed in " + CURRENCY_UNIT + "/kB\n" |
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.
Shouldn't this default be whatever maxTxFee
is, not ∞
?
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.
Fixed - it now outputs
2. allowhighfees|maxfeerate (boolean/numeric, optional, default=false/0.10) Allow
high fees (boolean) or reject transactions whose fee rate is higher than the
specified value (numeric), expressed in BTC/kB
for the default settings.
src/rpc/rawtransaction.cpp
Outdated
} else if (request.params[1].isNum()) { | ||
size_t weight = GetTransactionWeight(*tx); | ||
CFeeRate fr(AmountFromValue(request.params[1])); | ||
nMaxRawTxFee = fr.GetFee((weight+3)/4); |
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.
Might be good to add a quick comment here to clarify the +3/4
is for rounding
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.
Added note.
1a81743
to
da1234d
Compare
6c17985
to
7abd2e6
Compare
Addressed @MarcoFalke nits. |
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also #12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
} | ||
} | ||
return -1; | ||
} |
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.
re-utACK 7abd2e6
Sorry I only noticed this unused method in this hunk after merge 😿.
fa5c511 refactor: Remove unused function (MarcoFalke) Pull request description: Oversight of kallewoof and mine in #13541 (comment) Tree-SHA512: 2fd3c4ecde5d3c58b113aa58d606976ceb4998358bde0547ead8e83df210722fa9821d2c88b717bdd190ef71593cd9c0154c3a5d3f2ccc3af8cbf6c36aaa6d45
post-merge ACK 7abd2e6 (except the change to validation.cpp 🙈 ) |
Github-Pull: bitcoin#13541 Rebased-From: 6c0a6f7 Modifications: - Includes fix from bitcoin#15618 - Retains backward compatibility - Doesn't change all the unrelated tests
Github-Pull: bitcoin#13541 Rebased-From: 7abd2e6 Modifications: - Retains backward compatibility
Summary: * test: Refactor vout fetches in rpc_rawtransaction * wallet/rpc: add maxfeerate parameter to sendrawtransaction * wallet/rpc: add maxfeerate parameter to testmempoolaccept This is a backport of Core [[bitcoin/bitcoin#13541 | PR13541]] Test Plan: ninja all check-all Reviewers: #bitcoin_abc, majcosta Reviewed By: #bitcoin_abc, majcosta Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D6263
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also bitcoin#12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also bitcoin#12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also bitcoin#12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also bitcoin#12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also bitcoin#12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
7abd2e6 wallet/rpc: add maxfeerate parameter to testmempoolaccept (Karl-Johan Alm) 6c0a6f7 wallet/rpc: add maxfeerate parameter to sendrawtransaction (Karl-Johan Alm) e5efacb test: Refactor vout fetches in rpc_rawtransaction (Karl-Johan Alm) Pull request description: This adds a new `maxfeerate` parameter to `sendrawtransaction` which forces the node to reject a transaction whose feerate is above the given fee rate. This is a safety harness from shooting yourself in the foot and accidentally overpaying fees. See also bitcoin#12911. Tree-SHA512: efa50134a7c17c9330cfdfd48ba400e095c0a419cc45e630618d8b44929c25d780d1bb2710c1fbbb6e687eca373505b0338cdaa7f2ff4ca22636d84c31557a2e
This adds a new
maxfeerate
parameter tosendrawtransaction
which forces the node to reject a transaction whose feerate is above the given fee rate.This is a safety harness from shooting yourself in the foot and accidentally overpaying fees.
See also #12911.