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

MissingNonWitnessUtxo even before signing #1548

Open
stevenroose opened this issue Aug 12, 2024 · 4 comments
Open

MissingNonWitnessUtxo even before signing #1548

stevenroose opened this issue Aug 12, 2024 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@stevenroose
Copy link
Contributor

stevenroose commented Aug 12, 2024

When you provide witness_utxo but not non_witness_utxo, previously BDK would complain at sign-time. The solution was in the SignOptions:

			let opts = SignOptions {
				trust_witness_utxo: true,
				..Default::default()
			};

But now I am already getting this error at tx creation time when calling TxBuilder::finish.

I see that TxBuilder has a only_witness_utxo option now, but only affects TxBuilder's internal behavior and doesn't resolve the error. I am getting this error when not setting only_witness_utxo and by adding foreign inputs.

@stevenroose stevenroose added the bug Something isn't working label Aug 12, 2024
@notmandatory notmandatory added this to the 1.0.0-beta milestone Aug 22, 2024
@ValuedMammal
Copy link
Contributor

Would it be possible to come up with a test or code snippet that you believe should work if the bug was resolved?

@stevenroose
Copy link
Contributor Author

Here: https://github.com/stevenroose/bdk/tree/repro-foreign-utxo

So basically, removing that "only_witness_utxo" makes the build step fail. This might be intended behavior? But it's weird that if you don't indicate anything it will complain that non-witness utxo data is missing and you fix it by saying that you will not provide non-witness utxo data?

Before, only the signer would error when there was no non-witness utxo data and you would make the signer not error by adding the SignOptions field to make it trust the witness utxo data.

@stevenroose
Copy link
Contributor Author

stevenroose commented Oct 11, 2024

Like, in the very least, the "only_witness_utxo" method should be re-documented to say "do not require non-witness utxo data" instead of "do not provide non-witness utxo data". Because for foreign utxos, without that method, the builder also only provides witness utxo data but then somehow it is a problem while if you specifically tell you to do the same thing, it is not a problem.

I hope you can see what I'm saying. It might just be ok like this I guess, but it was a regression that wasn't like this before.

Also, you might want to provide non-witness utxo data for non-foreign inputs for example. Some signers might want/need them only for certain inputs so you can ignore them on the other ones. We use the foreign inputs for fee anchors and their value is negligible and their satisfaction is just the OP_TRUE witness script, so they might be treated very differently by signers.

@ValuedMammal
Copy link
Contributor

As a followup question do you think this logic should be changed to allow both taproot and segwitv0 inputs to not have a non_witness_utxo?

let is_taproot = foreign_psbt_input
.witness_utxo
.as_ref()
.map(|txout| txout.script_pubkey.is_p2tr())
.unwrap_or(false);
if !is_taproot
&& !params.only_witness_utxo
&& foreign_psbt_input.non_witness_utxo.is_none()
{
return Err(CreateTxError::MissingNonWitnessUtxo(outpoint));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants