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

backend: add argument to force highest fee rate in tx proposal #3259

Merged

Conversation

sutterseba
Copy link
Collaborator

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.

@sutterseba sutterseba requested a review from benma March 27, 2025 08:53
@@ -58,6 +58,7 @@ type TxProposalArgs struct {
SelectedUTXOs map[wire.OutPoint]struct{}
Note string
PaymentRequest *PaymentRequest
UseHighestFee bool
Copy link
Contributor

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 {
Copy link
Contributor

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".

Copy link
Collaborator Author

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

Copy link
Contributor

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 👍

@@ -325,6 +325,7 @@ export type TTxInput = {
sendAll: 'yes' | 'no';
selectedUTXOs: string[];
paymentRequest: Slip24 | null;
useHighestFee: boolean;
Copy link
Contributor

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) {
Copy link
Contributor

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 😭

@sutterseba sutterseba force-pushed the tx-proposal-use-highest-fee branch from 0b8a5f3 to b252f80 Compare March 27, 2025 09:45
@sutterseba sutterseba requested a review from benma March 27, 2025 09:48
Comment on lines 333 to 334
customFee?: never;
feeTarget?: never;
Copy link
Contributor

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.

Copy link
Contributor

@benma benma left a 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.
@sutterseba sutterseba force-pushed the tx-proposal-use-highest-fee branch from b252f80 to 986d3f2 Compare March 27, 2025 11:05
@sutterseba sutterseba merged commit 616727c into BitBoxSwiss:master Mar 27, 2025
9 of 10 checks passed
@sutterseba sutterseba deleted the tx-proposal-use-highest-fee branch March 27, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants