Skip to content
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

Switch AllowHighFee to MaxFeeRate #1415

Closed
wants to merge 4 commits into from

Conversation

vctt94
Copy link

@vctt94 vctt94 commented Apr 10, 2019

After commit bitcoin/bitcoin@c033c4b bitcoin switched allowHighFee to maxFeeRate on sendrawtransaction rpc command.

This PR switches AllowHighFees to MaxFeeRate as well.

@Roasbeef
Copy link
Member

Seems we also need to update the btcd server as well. Otherwise, we won't be able to respond to this new request.

@vctt94
Copy link
Author

vctt94 commented Apr 17, 2019

Thanks for reviewing.

I updated as requested.

rpcserver.go Outdated
@@ -3299,6 +3299,14 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan
// handleSendRawTransaction implements the sendrawtransaction command.
func handleSendRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
c := cmd.(*btcjson.SendRawTransactionCmd)
if s.cfg.TxIndex == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a pretty big downgrade if we now require the txindex just to send a transaction over the interface. Instead, during validation in the mempool, we know the direct fee since it's stored as part of the mempool transaction entry. So we can put the logic deeper into the mempool, accepting an optional argument of the max fee that the resulting transaction should be allowed to have.

rpcserver.go Outdated
@@ -3319,6 +3327,23 @@ func handleSendRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan st

// Use 0 for the tag to represent local node.
tx := btcutil.NewTx(&msgTx)

var totalSatoshiIn int64
inputs, err := fetchInputTxos(s, &msgTx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we can just check the UTXO set here. As if the inputs are already spent, it'll be rejected within the mempool anyway.

rpcserver.go Outdated
totalSatoshiOut += txOut.Value
}
txFee := totalSatoshiIn - totalSatoshiOut
if txFee > int64(*c.MaxFeeRate) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is comparing two different things. the limit is a feerate in sats/kB, which is being compared to the total fee in sats

rpcserver.go Outdated
txFee := totalSatoshiIn - totalSatoshiOut
if txFee > int64(*c.MaxFeeRate) {
return nil, &btcjson.RPCError{
Code: btcjson.ErrRPCDeserialization,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem like the correct response code, since the request was successfully deserialized

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returning wire.RejectInvalid now. I believe it is more appropriate

rpcserverhelp.go Outdated
"sendrawtransaction--result0": "The hash of the transaction",
"sendrawtransaction--synopsis": "Submits the serialized, hex-encoded transaction to the local peer and relays it to the network.",
"sendrawtransaction-hextx": "Serialized, hex-encoded signed transaction",
"sendrawtransaction-maxfeerate": "Reject transactions whose fee rate is higher than the specified value. The value is given in satoshis",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the intent is to match the bitcoind implementation, the maxfeerate is in sats/kB and not satoshis

https://github.com/bitcoin/bitcoin/pull/13541/files#diff-01aa7d1d32f1b9e5a836c9c411978918R1043

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@vctt94 vctt94 force-pushed the switchMaxFeeRate branch 2 times, most recently from 828f10d to ec2398a Compare April 24, 2019 18:51
@vctt94 vctt94 force-pushed the switchMaxFeeRate branch 4 times, most recently from 7e53c0f to ec1adc1 Compare April 24, 2019 19:16
@vctt94
Copy link
Author

vctt94 commented Apr 24, 2019

Thanks for pointing that Roasbeef. I moved the maxFeeRate to the ProcessTransaction method. Believe this looks better and there is no need of txindex, anymore.

Also fixed the others comments

@jakesylvestre
Copy link
Collaborator

@jcvernaleo (as per #1530)

  • Low priority
  • Bug (because RPC is outdated)
  • Outdated

@onyb
Copy link
Collaborator

onyb commented Nov 16, 2020

@vctt94 Can you please rebase this PR on latest master? Let's try to have dual compatibility, following the fixes to the sendrawtransaction command done in #1659.

@guggero guggero closed this Aug 3, 2023
@guggero
Copy link
Collaborator

guggero commented Aug 3, 2023

Not sure why GitHub closed this upon merge of another PR. Re-opening, sorry.

@guggero guggero reopened this Aug 3, 2023
@guggero guggero closed this Aug 3, 2023
@guggero
Copy link
Collaborator

guggero commented Aug 3, 2023

Okay, this seems to be a bug with the GitHub UI, will try again later.

@guggero guggero reopened this Aug 3, 2023
@guggero guggero closed this Aug 3, 2023
@guggero guggero reopened this Aug 4, 2023
@guggero guggero closed this Aug 4, 2023
@guggero
Copy link
Collaborator

guggero commented Aug 4, 2023

Okay, I'm giving up. No idea why GitHub doesn't let me re-open the PR, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants