Skip to content
Open
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
8 changes: 7 additions & 1 deletion counterparty-core/counterpartycore/lib/parser/utxosinfo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
MAX_VOUT = 0xFFFFFFFF


def is_utxo_format(value):
if not isinstance(value, str):
return False
Expand All @@ -6,7 +9,10 @@ def is_utxo_format(value):
return False
if not values[1].isnumeric():
return False
if str(int(values[1])) != values[1]:
vout = int(values[1])
if str(vout) != values[1]:
return False
if vout > MAX_VOUT:
return False
try:
int(values[0], 16)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from counterpartycore.lib.parser import utxosinfo

TXID = "0" * 64


def test_is_utxo_format_rejects_vout_above_uint32():
assert utxosinfo.is_utxo_format(f"{TXID}:0")
assert utxosinfo.is_utxo_format(f"{TXID}:4294967295")
assert not utxosinfo.is_utxo_format(f"{TXID}:4294967296")
assert not utxosinfo.is_utxo_format(f"{TXID}:999999999999999999999")