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

tapfreighter+tapgarden: prevent fee overpayment #555

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

jharveyb
Copy link
Collaborator

@jharveyb jharveyb commented Oct 9, 2023

Fixes #538.

Adds sanity checks for signed TXs, before TX broadcast, to allow for more complete unwinding of a mint or send.

@@ -1397,6 +1399,12 @@ func (f *AssetWallet) AnchorVirtualTransactions(ctx context.Context,
return nil, fmt.Errorf("unable to extract psbt: %w", err)
}

// Final TX sanity check.
err = blockchain.CheckTransactionSanity(btcutil.NewTx(finalTx))
Copy link
Member

Choose a reason for hiding this comment

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

👍


// The fee may exceed the total value of the change output, which means
// this spend is impossible with the given inputs and fee rate.
if changeValue-feeDelta < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can just call CheckTransactionSanity again here? It should handle catching the negative output.

Even with that though, if we ended up in that case, even with a fee estimator that returned "nothing" (so defaults to 253 sat/kw), we have a bug here if we're arriving at negative outputs.

@Roasbeef Roasbeef marked this pull request as ready for review October 12, 2023 03:49
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 🐠

Plan is still to circle back re testing and refactoring here.

@Roasbeef Roasbeef merged commit 7bd69af into main Oct 12, 2023
14 checks passed
@guggero guggero deleted the fee_overpayment_fixes branch October 12, 2023 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[bug] Fee estimation creates negative output value
3 participants