BitBoxSwiss / bitbox02-firmware

Firmware code of the BitBox02 hardware wallet
https://bitbox.swiss/bitbox02
Apache License 2.0
217 stars 81 forks source link

bitcoin/signtx: allow non-change internal outputs #1106

Closed benma closed 10 months ago

benma commented 11 months ago

Outputs of a btc transaction can be marked internal ("ours") or external.

Before now, internal ones were forced to be change outputs, and the keypath was validated to be a change keypath.

This commit changes this so that the output can be marked internal and not be a change output, but a regular output of the same account.

The reason for this change is that some wallets supply the keypath information to PSBTs even for non-change outputs of the same account. Until now, e.g. in HWI, we checked if the keypath was available for an output, and stripped it if it was a change keypath, so the BitBox02 would not error out. With miniscript, such a check becomes very difficult, as the change keypath does not need to be on /1/*, but could be anywhere, e.g. in a policy like wsh(pk/@0/<10;11>/*)), where the change output is at /11/*.