HWI icon indicating copy to clipboard operation
HWI copied to clipboard

Accept an encoded Base64 PSBT (as both str and bytes) or a PSBT object as input to sign_tx

Open fametrano opened this issue 3 years ago • 0 comments

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)

fametrano avatar Dec 09 '20 23:12 fametrano