Reorganize project structure

This commit is contained in:
zv
2026-03-06 18:20:43 +01:00
parent 04c209ae23
commit 7e0c0afddf
26 changed files with 1520 additions and 1311 deletions

View File

@@ -0,0 +1,28 @@
from __future__ import annotations
from .common import base58check_verify, bech32_decode
def validate_ltc_address(address: str) -> tuple[bool, str]:
address = address.strip()
if address.lower().startswith("ltc1"):
hrp, data, spec = bech32_decode(address)
if hrp is None:
return False, "Invalid Bech32 or Bech32m checksum"
if hrp != "ltc":
return False, "Invalid HRP for LTC"
if not data:
return False, "Missing witness program"
return True, f"Valid {spec} address"
if not (address.startswith("L") or address.startswith("M") or address.startswith("3")):
return False, "LTC Base58 addresses must start with L, M, or 3"
valid, reason, version, payload_len = base58check_verify(address)
if not valid:
return False, reason
if payload_len != 21:
return False, "Unexpected Base58 payload length"
if version not in (0x30, 0x32, 0x05):
return False, "Invalid LTC version byte"
return True, "Valid Base58Check address"