Skip to content
Closed
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
11 changes: 7 additions & 4 deletions allways/chain_providers/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,14 @@ def get_balance(self, address: str) -> int:
return 0

def is_valid_address(self, address: str) -> bool:
"""Validate an SS58 address."""
"""Validate an SS58 address (length, charset, and checksum)."""
if not address:
return False
try:
if not address or len(address) != 48:
return False
return bool(re.match(r'^[1-9A-HJ-NP-Za-km-z]{48}$', address))
from scalecodec.utils.ss58 import ss58_decode

ss58_decode(address)
return True
except Exception:
return False

Expand Down