-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[bug]: 0.15.3 requires additional sats to spend a UTXO completely when P2TR #7079
Comments
I tried to reproduce this on regtest and wasn't able to. Did I follow your instructions correctly? Here's the first PSBT I created, with a 546 sat output sent to a P2TR address:
Then I added the change output and the 546 sats to send 89985713 sats to the same P2TR address:
Which I was then able to finalize into:
Do you maybe have an example of a PSBT that is failing? What inputs are you using? |
Sure I can reproduce it on regtest Create a template PSBT:
The PSBT is:
Now that I have that, I will make the solo output with the same input but an aggregate output (with FundPsbt):
This produces the error (on LND 0.15.3) |
Hello. Is the bug being looked at? I am on 0.17.5 and cannot spend UTXOs exactly on Testnet. I learned to keep haircutting the output amount by a few sats until the error goes away. |
This should be fixed with @alexbosworth since this explicitly mentions |
I didn't play with the changes, but I read it to understand that the old behavior would remain the same and the new behavior would only trigger via the new arguments? |
Correct, the new behavior only triggers via the new |
If it's fixed sure I just didn't get a chance to test it locally yet |
Fixed by #8378. |
Hello. Could you explain how to use this new walletrpc.FundPsbtRequest has a new Template available FundPsbtRequest_CoinSelect with one field CoinSelect:
But where do I get an existing Psbt to provide to it? I invoke FundPsbt to create a Psbt like this (with one output):
...but it fails unless I haircut the output amount. What am I missing? Thanks!! |
You need to specify Line 1246 in 036a5a9
The easiest way to create the template PSBT is probably to create it manually from exactly the inputs and outputs you want. |
Thanks, but this "easiest way" is over my head. Too ingrained into testing environment. I would appreciate a simple example with one utxo as input, one address as output, a fee rate given as a parameter and the resulting amount paid being the utxo amount less the fee. |
Lines 1080 to 1098 in 9f9d1c9
And then this:
|
Thank you. This was helpful. The template does not work as I expected. It adds a random additional UTXO to inputs, and sends the total to the single output address. Not a good behavior when sending funds to a third party. I want to spend exactly the selected UTXOs with the fees being deducted from their total amount. I resorted to using FundPsbtRequest_Raw first with zero outputs, to make it construct one change output. Then I decode that psbt with bitcoin core API to extract the total amount of fees. After that I reduce my sendAmount by that amount of fees and use FundPsbt with manually constructed PSBT. Pretty much what I did before, but no need to solve for additional haircuts until FundPsbtRequest_Raw funds successfully. Not very elegant, but it works. How can I extract the amount of fees or output value from pbst bytes using btcd? |
I think you can achieve what you want in one step by specifying the input you want and using 0 as the output amount, using the |
0 amount did not work, but 1 sat indeed achieved what I wanted. thank you! |
I also created a test case for this and found the changes to be working |
Background
I have a method that tries to find the maximum that can be spent in X UTXOs for the purpose of spending the entire UTXO.
In LND 0.15.2 and before, (including on P2TR outputs), my estimation method could produce a funded PSBT that spent down completely a UTXO, but on LND 0.15.3 my estimation method fails and requires additional funds
Your environment
Steps to reproduce
Expected behavior
In LND 0.15.2 and before, the change value represents what could have been added to the main output. Funding the PSBT works by adding in the change over into the main value and then re-funding.
Actual behavior
In LND 0.15.3 in the case of sending to P2TR, trying to spend the change value as 1 output results in an error saying
could not add change address to database: fee estimation not successful: insufficient funds available to construct transaction
In reality I am trying to remove the need for a change address by figuring out what can be spent into a single output given a set of UTXOs, but this is already a known issue.
Workaround
This error does not happen in 0.15.2 or when sending to P2WPKH outputs, but in the case of P2TR on LND 0.15.3 the fix is to take the fee rate multiplied by 10 and subtract that from the final output amount, any more sats spent than that will result in the error.
The text was updated successfully, but these errors were encountered: