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

Allowing both nonWitnessUtxo and witnessUtxos on inputs to allow creating PSBTs for Trezor signing #1595

Closed
KayBeSee opened this issue Jul 9, 2020 · 4 comments

Comments

@KayBeSee
Copy link

KayBeSee commented Jul 9, 2020

I am trying to send a transaction and sign it with a Trezor One hardware wallet. With the latest firmware, they require including the previous transaction hex to prevent the recent fee attack that could happen on hardware wallets.

I read through this thread that had a similar issue, but this was before the bug was announced.

When I try to add the nonWitnessUtxo I get Error: Can not add duplicate data to input

Some other links I found relating to it:
https://blog.trezor.io/details-of-firmware-updates-for-trezor-one-version-1-9-1-and-trezor-model-t-version-2-3-1-1eba8f60f2dd
bitcoin-core/HWI#338

@junderw
Copy link
Member

junderw commented Jul 9, 2020

remove the witnessUtxo first.

Why are both required? nonWitnessUtxo contains all the information in witnessUtxo.

@junderw
Copy link
Member

junderw commented Jul 9, 2020

Nowhere does it say on their blog it needs both.

They say to supply nonWitnessUtxo in all cases. So instead of adding witnessUtxo only add nonWitnessUtxo. If some other app is adding it and sending it to your app, tell them to only have one.

@junderw junderw closed this as completed Jul 9, 2020
@KayBeSee
Copy link
Author

KayBeSee commented Jul 10, 2020

Hey Jon, thanks for your prompt response per usual.

I went ahead and removed the witnessUtxo and the witnessScript and replaced them with the nonWitnessUtxo and redeemScript. I then sent the PSBT to the Trezor using the newest version of HWI but kept getting {"error": "DataError: Transaction must have at least one input", "code": -13}

I went and commented out lines 98-100 in the BIP174 package, added the witnessUtxo, witnessScript back and removed the redeemScript, constructed the PSBT and sent it to the Trezor using HWI and it worked flawlessly.

You are right from my understanding, I don't know why I would need both the nonWitnessUtxo in addition to the witnessUtxo and witnessScript since those should both be in the nonWitnessUtxo. From the conversations I have read about it I think there is some sort of detection of Segwit inputs that happens and if it detects that it also checks for nonWitnessUtxo? (basically the they decided to just throw the full tx on the nonWitnessUtxo field to make sure there isn't a massive fee).

Again, I'm not super well versed in what is going on behind the scenes. It seems that because of this recent BIP174 bug, and the patch that Trezor has decided to employ, we need both in order for the Trezor to be able to sign (which sucks).

bitcoin-core/HWI#340
btcpayserver/btcpayserver#1631

@junderw
Copy link
Member

junderw commented Jul 10, 2020

You should not change witnessScript to redeemScript.

That is your problem.

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

No branches or pull requests

2 participants