Skip to content

[bug]: Small Anchor Output Amounts Trigger False Positive in Fee Tolerance Check #1417

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

Open
SevenLiquor opened this issue Mar 3, 2025 · 2 comments · May be fixed by #1539
Open

[bug]: Small Anchor Output Amounts Trigger False Positive in Fee Tolerance Check #1417

SevenLiquor opened this issue Mar 3, 2025 · 2 comments · May be fixed by #1539
Assignees
Labels
bug Something isn't working needs triage

Comments

@SevenLiquor
Copy link

Background

When sending using multiple assets' UTXOs, the selection of BTC's UTXOs triggers the protection mechanism of fees.
In my test, I used the UTXO of 4 assets to complete a transaction. The node might consider that the BTC amount in the anchored UTXO was sufficient to complete this transaction, so no other unanchored UTXO was used as the input to provide the fee.
This judgment is reasonable, but it will lead to another problem.The total input for this transaction is only 4000 sats, but a portion of it must be used as fee.The node has a protection mechanism. The fee must be less than 20% of the total output.

coin_select.go:146

// sanityCheckFee checks if the specified fee amounts to over 20% of the total
// output amount and raises an error.
func sanityCheckFee(totalOut, fee btcutil.Amount) error {
	// Fail if more than 20% goes to fees.
	// TODO(halseth): smarter fee limit. Make configurable or dynamic wrt
	// total funding size?
	if fee > totalOut/5 {
		return fmt.Errorf("fee %v on total output value %v", fee,
			totalOut)
	}
	return nil
}

This will make it very difficult for this transaction to be completed.Users can also choose to use a smaller or larger Fee to meet this limit, but this will increase the risk and cost of the transaction.

Your environment

version: litd 0.14.1-alpha
mode: integrated
os: ubuntu

Steps to reproduce

1.Keep four UTXOs of the same asset in Tapd.
2.Send to an address whose value is equivalent to the total sum of 4 UTXO assets.(When sat_per_vbyte = 3,4,5,6, even if there is sufficient BTC, it will not be used.Until sat_per_vbyte = 7)

··sh
./ta a s --addr taprt1qqqszqspqqzzp7z4kwnxm4gfz2mu6v8swrcgslg03dqahqlef69h4k3qtnqcw6lnqcss9dg4jyae57lmn07qevrgd4amlnlgyfhnf8wen9q7rjm7jcgrx4k4pqss9uunnl645tzqrafgv0zterjxk36qacvpcvy7sj3zmtydxzfg4yx2pgqnqrppw4hxjan9wfek2unsvvaz7te3xvezuv3nxghrzvpe9curgw3cxs6rxfu5ekw --sat_per_vbyte 3
···

Expected behavior

Successfully sent assets

Actual behavior

Error:

[tapcli] unable to send assets: rpc error: code = Unknown desc = unable to anchor virtual transactions: unable to fund psbt: unable to fund psbt: rpc error: code = Unknown desc = error calculating change amount: fee 0.00001108 BTC on total output value 0.00002892 BTC

log:

2025-03-03 14:58:55.230 [INF] LITD: Handling gRPC request: /taprpc.TaprootAssets/SendAsset
2025-03-03 14:58:55.434 [INF] FRTR: Received to send request to 1 addrs: [TapAddr{id=f855b3a66dd50912b7cd30f070f0887d0f8b41db83f94e8b7ada205cc1876bf3, amount=48, script_key=02b515913b9a7bfb9bfc0cb0686d7bbfcfe8226f349dd99941e1cb7e96103356d5}]
2025-03-03 14:58:55.435 [INF] FRTR: ChainPorter executing state: SendStateVirtualCommitmentSelect
2025-03-03 14:58:55.494 [INF] FRTR: Identified 4 eligible asset inputs for send of 48 to group_key=, asset_id=f855b3a66dd50912b7cd30f070f0887d0f8b41db83f94e8b7ada205cc1876bf3, min_amt=48: [df3f66e30010956c60f38649cd8f57f9a9f8debe037bcff302f44735c7ed007c:1 5ad82fc115bccf18f091a0a0b2b3abf2a47d55ed44f0908c42c41d537c46a88e:1 ba038bd8d6101b8999e69009d7cd86a5be75c8962f4aa4ba445bd3b640e0b25a:1 350ea4fa9767693121367da086862cdb7ebab1847999c8402f3d585c1918eab4:1]
2025-03-03 14:58:55.499 [INF] FRTR: Selected 4 asset inputs for send of 48 to f855b3a66dd50912b7cd30f070f0887d0f8b41db83f94e8b7ada205cc1876bf3
2025-03-03 14:58:55.534 [INF] FRTR: ChainPorter executing state: SendStateVirtualSign
2025-03-03 14:58:55.535 [INF] FRTR: Generating Taproot Asset witnesses for send to: 02b515913b9a7bfb9bfc0cb0686d7bbfcfe8226f349dd99941e1cb7e96103356d5
2025-03-03 14:58:55.558 [INF] FRTR: ChainPorter executing state: SendStateAnchorSign
2025-03-03 14:58:55.558 [INF] FRTR: sending with manual fee rate
2025-03-03 14:58:55.560 [INF] FRTR: Sending with fee rate: 3000 sat/kvb
2025-03-03 14:58:55.560 [INF] FRTR: Constructing new Taproot Asset commitments for send to: 02b515913b9a7bfb9bfc0cb0686d7bbfcfe8226f349dd99941e1cb7e96103356d5
2025-03-03 14:58:55.676 [ERR] RPCS: [/walletrpc.WalletKit/FundPsbt]: error calculating change amount: fee 0.00001108 BTC on total output value 0.00002892 BTC
2025-03-03 14:58:55.685 [ERR] FRTR: Error evaluating state (SendStateAnchorSign): unable to anchor virtual transactions: unable to fund psbt: unable to fund psbt: rpc error: code = Unknown desc = error calculating change amount: fee 0.00001108 BTC on total output value 0.00002892 BTC
2025-03-03 14:58:55.686 [ERR] RPCS: [/taprpc.TaprootAssets/SendAsset]: unable to anchor virtual transactions: unable to fund psbt: unable to fund psbt: rpc error: code = Unknown desc = error calculating change amount: fee 0.00001108 BTC on total output value 0.00002892 BTC
@SevenLiquor SevenLiquor added bug Something isn't working needs triage labels Mar 3, 2025
@ffranr ffranr changed the title [bug]: A special case when sending assets [bug]: Small anchor output amounts causes fee tolerence check false positive Mar 7, 2025
@ffranr ffranr changed the title [bug]: Small anchor output amounts causes fee tolerence check false positive [bug]: Small Anchor Output Amounts Trigger False Positive in Fee Tolerance Check Mar 7, 2025
@ffranr
Copy link
Contributor

ffranr commented Mar 7, 2025

Thank you for opening this issue. I've rewritten the title for clarity. I've also flagged this issue internally to the team.

@GeorgeTsagk
Copy link
Member

Hi @SevenLiquor , thanks for opening this issue!

So a while back we added an override option to LND's FundPsbt (see related LND PR). This was intended to bump up the allowed ratio of fees to total output amounts, which would let taproot asset UTXOs pay more than the previously default 20%.

We forgot to actually make use of this new parameter in tapd, so I'll make a PR now that bumps the allowed ratio to something greater. Thanks again for flagging this!

@linden linden linked a pull request May 14, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: 🔖 Ready
Development

Successfully merging a pull request may close this issue.

3 participants