Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ jobs:
hwilib/hwwclient.py
hwilib/__init__.py
hwilib/key.py
hwilib/psbt.py
hwilib/udevinstaller.py
14 changes: 8 additions & 6 deletions hwilib/psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<I", v)[0]
if self.time_locktime < 500000000:
time_locktime = struct.unpack("<I", v)[0]
if time_locktime < 500000000:
raise PSBTSerializationError("Input time based locktime is less than 500000000")
self.time_locktime = time_locktime
elif key_type == PartiallySignedInput.PSBT_IN_REQUIRED_HEIGHT_LOCKTIME:
if self.version == 0:
raise PSBTSerializationError("PSBT_IN_REQUIRED_HEIGHT_LOCKTIME is not allowed in PSBTv0")
Expand All @@ -302,9 +303,10 @@ def deserialize(self, f: Readable) -> None:
v = deser_string(f)
if len(v) != 4:
raise PSBTSerializationError("Input height based locktime is not 4 bytes")
self.height_locktime = struct.unpack("<I", v)[0]
if self.height_locktime == 0 or self.height_locktime >= 500000000:
height_locktime = struct.unpack("<I", v)[0]
if height_locktime == 0 or height_locktime >= 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")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
Loading