HWI
HWI copied to clipboard
Accept an encoded Base64 PSBT (as both str and bytes) or a PSBT object as input to sign_tx
To facilitate interoperability across different software systems with possibly different implementations of the PSBT standard, B174 advocates base64 encoding as "lingua franca" for PSBT.
For this reason, sign_tx
should primarily accept that as input, without forcing other system/libraries to use the provided PSBT object as the only possible input.
This pull request leverages https://github.com/bitcoin-core/HWI/pull/409 to perform a short
if isinstance(psbt, (str, bytes)):
psbt2 = PSBT()
psbt2.deserialize(psbt)
instead of treating bytes and str separately. Anyway, if https://github.com/bitcoin-core/HWI/pull/409 is rejected, this PR could be adapted to be indipendent.
On a related note, this patch would just be
if isinstance(psbt, (str, bytes)):
psbt = PSBT.deserialize(psbt)
if PSBT.deserialize would be defined as @classmethod (e.g. see https://github.com/btclib-org/btclib/blob/840c3b8ae285579490a374c626afac8863e7b813/btclib/psbt.py#L205)