B2: network profile for mainnet and regtest, explicit confirmation for mainnet (ADR-58, ELC-30)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 15:38:29 +01:00
1 parent 3ee60a23da
commit 9c832fd3d2
16 files changed
+261 -36

No files matched your search

+10 -5
View File
@@ -12,16 +12,21 @@ tells the user (bech32 `plm1q...` only).
from embit import script
from embit.base import EmbitError
from plm_engine.network import PLM_MAINNET
_BECH32_PREFIX = PLM_MAINNET["bech32"] + "1"
from plm_engine.network import MAINNET, Profile
def is_valid_plm_address(address: str) -> bool:
if not address.startswith(_BECH32_PREFIX):
def is_valid_address(address: str, profile: Profile) -> bool:
"""A well-formed segwit address on this profile's chain: its hrp is the profile's (ADR-58), so a mainnet
`plm1…` is refused on regtest and the other way round."""
if not address.startswith(profile.hrp + "1"):
return False
try:
script.Script.from_address(address)
except EmbitError:
return False
return True
def is_valid_plm_address(address: str) -> bool:
"""Mainnet only: what the old stack has always checked."""
return is_valid_address(address, MAINNET)