-
Notifications
You must be signed in to change notification settings - Fork 213
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
Signing a P2WSH multisig input fails on updated Ledger firmware & Bitcoin app #680
Comments
cc @bigspider |
Hi @dspicher, make sure you install the "Bitcoin Test" app for testnet, not the mainnet one. Other than that, the issue is probably that the psbt is missing the PSBT_GLOBAL_XPUB fields; HWI uses them to reconstruct the exact multisig policy (it worked with the legacy app because it would essentially blind sign P2SH scripts, which was not very secure particularly because the app would not recognize the change address). The PSBT_IN_BIP32_DERIVATION also seem incorrect, as they should contain the exact derivations used for that input − it appears indeed that some derivations info that should rather go into the PSBT_GLOBAL_XPUB was instead added in the PSBT_IN_BIP32_DERIVATION field of the input. |
Hi @bigspider Thanks a lot for your answer, I appreciate your input.
Good reminder, thanks. The error behaviour is the same when I use the BTC Test app (although the warning about the unusal keypath is gone 👍).
I cannot confirm this for the PSBT I pasted above. When deserializing it with from hwilib.psbt import PSBT
psbt = PSBT()
psbt.deserialize("psbt base64 from above")
print(f"Global Xpubs: {len(psbt.xpub)}")
first_key = list(psbt.xpub.keys())[0]
print(f"First item: {first_key.hex()}: {psbt.xpub[first_key]}")
print(f"Per-input HD Keypaths: {len(psbt.inputs[0].hd_keypaths)}")
first_key = list(psbt.inputs[0].hd_keypaths.keys())[0]
print(f"First item: {first_key.hex()}: {psbt.inputs[0].hd_keypaths[first_key]}") This prints the following:
This seems to be in line with BIP174 where I corrected one mistake I found with the PSBT I pasted above though: All but one |
One other note-worthy thing about my use-case: At the time of creating the first signature, I don't know the fingerprints of the other signers yet. That's why you find all-zero dummy fingerprints in the PSBT for four of the five signers. |
Ah, indeed, sorry for the oversight. I decoded the PSBT with https://bip174.org and I wrongly assumed it would show the global xpubs if present. I'm not seeing other issues with the PSBT. The missing key origin info for the cosigners shouldn't cause problems, as far as I can tell. If you're able to produce a similar PSBT for a policy where you can share the seed, I'll be happy to try to reproduce it locally. |
Hehe, same here, I guess it's time for afilini/bip174.org#20 to be implemented.
ACK.
That's great, thanks for the offer! I will first try to solve it by comparing against an Electrum PSBT, and post back here afterwards in either case. |
Hi @bigspider, I figured out the issue. It turns out that this was the root cause:
This conflicted with the way the multisig wallet is parsed for registration, leading to four identical xpubs ending up in the wallet description. Using the encoded fingerprint in each xpub instead solved the problem. Thanks for your help. |
HWI version: 2.2.1
I have an application where I am using HWI to sign for P2WSH 4-of-5 multisig inputs.
Under Ledger Firmware 2.0.2 and Bitcoin App 2.0.6 this worked fine.
After updating to Ledger Firmware 2.1.0 and Bitcoin App 2.1.2 I run into the following error:
('0x6a82', 'Error in <BitcoinInsType.REGISTER_WALLET: 2> command', '')
The hardware wallet also warns about an unusual derivation path before the signature is attempted, although it is the standard multisig P2WSH path at
48'/1'/0'/2'
(so this is probably caused by the testnet1'
index).The PSBT I am trying to sign is of the following form (again testnet):
PSBT
cHNidP8BAF4CAAAAAdj1UCoc6OtNuOSR3Vx0kfjoNaNHis+90R0Z9SWELyPOAAAAAAD/////AYOdaQAAAAAAIgAgKu1VZQCzBYRM4cEXY0P9aq3TUvb1Z8pjzGdC5VYLt5KzNCUATwEENYfPBAqN4sKAAAACPiCczVE7CeOzkKpKSRm+NE2fhtT8MC5o0HVep1b/HbEDa+uxz0QawJa68KtPzrY3jE0zGUm8ZIH0HuWhYYUwj3QUAAAAADAAAIABAACAAAAAgAIAAIBPAQQ1h88EI8TfHIAAAAJecU20F+6oELVRgBDYCySsuQOL51kpuErCr8P+vIN1PwLClKGOinWEsi8vxXAwO6ligMq912brI+JxBbeAVtvwCBQK0Hz9MAAAgAEAAIAAAACAAgAAgE8BBDWHzwSAygJigAAAAtWl3dyTI/SbLXqP3wxZSRHtsxoRx101l1CAFmx38PN7AujXFbDqPePtk5x/P/E8yKeLT5y5QPB5/NdIhtQOS5HPFAAAAAAwAACAAQAAgAAAAIACAACATwEENYfPBLjzNH2AAAAC5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embit library to prepare the PSBT, which makes me think that this sounds suspiciously similar: cryptoadvance/specter-desktop#1840. But the issue seems to have been fixed under the versions I am running.
hwilib.commands.enumerate
returns the following for the Ledger device:The
app-bitcoin-new
release notes do not contain obvious hints at what could be going wrong.The text was updated successfully, but these errors were encountered: