-
Notifications
You must be signed in to change notification settings - Fork 96
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
backend: add argument to force highest fee rate in tx proposal #3259
backend: add argument to force highest fee rate in tx proposal #3259
Conversation
backend/accounts/account.go
Outdated
@@ -58,6 +58,7 @@ type TxProposalArgs struct { | |||
SelectedUTXOs map[wire.OutPoint]struct{} | |||
Note string | |||
PaymentRequest *PaymentRequest | |||
UseHighestFee bool |
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.
maybe it makes sense to move this up to the other fee fields and add a comment that CustomFee
and FeeTargetCode
don't apply when UseHighestFee
is true.
@@ -39,8 +39,7 @@ const unitSatoshi = 1e8 | |||
// fee target (priority) if one is given, or the provided args.FeePerKb if the fee taret is | |||
// `FeeTargetCodeCustom`. | |||
func (account *Account) getFeePerKb(args *accounts.TxProposalArgs) (btcutil.Amount, error) { | |||
isPaymentRequest := args.PaymentRequest != nil | |||
if args.FeeTargetCode == accounts.FeeTargetCodeCustom && !isPaymentRequest { | |||
if args.FeeTargetCode == accounts.FeeTargetCodeCustom && !args.UseHighestFee { |
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.
drop the first condition? not sure why it should be "custom".
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.
but that part is specifically to evaluate the custom fee rate, no? if args.UseHighestFee
is further down
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 yes, I missed that 👍
frontends/web/src/api/account.ts
Outdated
@@ -325,6 +325,7 @@ export type TTxInput = { | |||
sendAll: 'yes' | 'no'; | |||
selectedUTXOs: string[]; | |||
paymentRequest: Slip24 | null; | |||
useHighestFee: boolean; |
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.
could be cool to make this type a union type to exclude illegal combinations, similar to
export type TPeripheral = { |
And prevent using e.g. customFee
when useHighestFee
is true.
@@ -39,8 +39,7 @@ const unitSatoshi = 1e8 | |||
// fee target (priority) if one is given, or the provided args.FeePerKb if the fee taret is | |||
// `FeeTargetCodeCustom`. | |||
func (account *Account) getFeePerKb(args *accounts.TxProposalArgs) (btcutil.Amount, error) { |
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 whole file is severly lacking unit tests. Some day 😭
0b8a5f3
to
b252f80
Compare
frontends/web/src/api/account.ts
Outdated
customFee?: never; | ||
feeTarget?: never; |
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 you can just remove those.
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
Previously, the highest fee rate was automatically applied to all transaction proposals with a SLIP-24 payment request. For selling and spending integrations that do not use SLIP-24 payment requests, there should also be an option to trigger this same behaviour. This commit replaces the previous conditioning on payment requests with a general boolean field that is set independently and can be used for other integrations. This also allows setting a custom fee rate for transaction proposals with payment requests, if needed. The TTxInput type excludes illegal combinations of this setting and feeTarget or customFee, as either the highest fee should automatically be used, or an explicitly specified fee target.
b252f80
to
986d3f2
Compare
Previously, the highest fee rate was automatically applied to all transaction proposals with a SLIP-24 payment request. For selling and spending integrations that do not use SLIP-24 payment requests, there should also be an option to trigger this same behaviour.
This commit replaces the previous conditioning on payment requests with a general boolean field that is set independently and can be used for other integrations. This also allows setting a custom fee rate for transaction proposals with payment requests, if needed.