Skip to content

Incorrect script type on SegWit input with non_segwit_utxo #338

@matejcik

Description

@matejcik

The following PSBT fails to sign correctly on Trezor:
(Testnet, seed "all all all...")

cHNidP8BAHECAAAAAecEAgWR8szJlB6pdc1WWqPRPz7QtRaBvrL8N+uBEwYJAQAAAAD9////AlDDAAAAAAAAFgAUoba87EO4px+ZskFuuEgHIKIyLfvDwgAAAAAAABYAFBzJhv75wfAhWc0Vbs53Trx3gtM2AAAAAAABAIgCAAAAAUN0ZYfD6gHGgpUpLr4s2HZ/THP5NZQxl/ZEoutJhmNPAAAAABcWABTHzP6hfUod5XE9TOw2dG2zX+oKJ/7///8CgKkQAAAAAAAWABSN0irV2k8nVHXyPE7hG+ZhfoOH4aCGAQAAAAAAFgAUMubjebQZ7UyhjcnN4t1BBosX/E34phoAIgYCwdb62tbxWXu7isZaztYffSFQCzUPXEJQkLzJXtwIKsIYXJ4ijVQAAIABAACAAwAAgAAAAAADAAAAAAAiAgJXlDJA50X02ihEXTHJgjWpI9BcMt8z3XsLBkeJGcNtrRhcniKNVAAAgAEAAIADAACAAQAAAAQAAAAA

It is spending a SegWit output, but the PSBT provides non_segwit_utxo field with the full transaction (this is allowed by the spec).

HWI uses this to determine that the script-type should be SPENDADDRESS (per https://github.com/bitcoin-core/HWI/blob/master/hwilib/devices/trezor.py#L166-L168). It produces an incorrect signature and bitcoind won't finalize the transaction.

Manually changing SPENDADDRESS to SPENDWITNESS produces a correct signature that is accepted by network (https://tbtc1.trezor.io/tx/5d05e39c686e73e61490f196f3a6d6aa15beddffa5b5c1fc07f74f8c4d12c312)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions