From 37643bd8e4f86324b75723525149eb945275395c Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Mon, 24 Aug 2026 12:51:22 +0200 Subject: [PATCH] psbt: enable type checking --- .github/workflows/type-check.yml | 1 + hwilib/psbt.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/type-check.yml b/.github/workflows/type-check.yml index 679844c08..7894fca82 100644 --- a/.github/workflows/type-check.yml +++ b/.github/workflows/type-check.yml @@ -40,4 +40,5 @@ jobs: hwilib/hwwclient.py hwilib/__init__.py hwilib/key.py + hwilib/psbt.py hwilib/udevinstaller.py diff --git a/hwilib/psbt.py b/hwilib/psbt.py index 429cf355d..925ac24f1 100644 --- a/hwilib/psbt.py +++ b/hwilib/psbt.py @@ -289,9 +289,10 @@ def deserialize(self, f: Readable) -> None: v = deser_string(f) if len(v) != 4: raise PSBTSerializationError("Input time based locktime is not 4 bytes") - self.time_locktime = struct.unpack(" None: v = deser_string(f) if len(v) != 4: raise PSBTSerializationError("Input height based locktime is not 4 bytes") - self.height_locktime = struct.unpack("= 500000000: + height_locktime = struct.unpack("= 500000000: raise PSBTSerializationError("Input height based locktime is not greater than 0 and less than 500000000") + self.height_locktime = height_locktime elif key_type == PartiallySignedInput.PSBT_IN_TAP_KEY_SIG: if key in key_lookup: raise PSBTSerializationError("Duplicate key, input Taproot key signature already provided") @@ -1072,7 +1074,7 @@ def cache_unsigned_tx_pieces(self) -> None: if self.version == 0: self.setup_from_tx(self.tx) - def setup_from_tx(self, tx: CTransaction): + def setup_from_tx(self, tx: CTransaction) -> None: """ Fills in the PSBTv2 fields for this PSBT given a transaction @@ -1159,7 +1161,7 @@ def get_unsigned_tx(self) -> CTransaction: tx.rehash() return tx - def _convert_version(self, version) -> None: + def _convert_version(self, version: int) -> None: self.version = version for psbt_in in self.inputs: psbt_in.version = version