bank: auto-account username prefix goa-bank-acc-<id>

Personal auto-accounts use usernames of the form goa-bank-acc- plus a random
hex id so they are easy to spot in admin lists and distinct from explorer
or hand-registered users.
This commit is contained in:
Hernâni Marques 2026-07-10 20:43:45 +02:00
parent f341116371
commit bb7bd5e73c
No known key found for this signature in database

View file

@ -124,9 +124,8 @@ def mint_withdraw() -> dict:
def _rand_username() -> str:
# bank usernames: keep simple [a-z0-9]
alphabet = string.ascii_lowercase + string.digits
return "guest" + "".join(secrets.choice(alphabet) for _ in range(8))
# goa-bank-acc-<uuid> — unique guest id, bank-safe [a-z0-9-]
return "goa-bank-acc-" + secrets.token_hex(8)
def _rand_password() -> str:
@ -139,7 +138,9 @@ def create_personal_account() -> dict:
"""Public registration: auto username/password, balance starts at 0."""
username = _rand_username()
password = _rand_password()
name = "Guest " + username[5:9].upper()
# short label from id suffix
suffix = username.rsplit("-", 1)[-1][:8]
name = "GOA bank acc " + suffix
code, body = http_json(
"POST",
f"{BANK}/accounts",
@ -153,6 +154,8 @@ def create_personal_account() -> dict:
# retry once on conflict
if code in (409, 400):
username = _rand_username()
suffix = username.rsplit("-", 1)[-1][:8]
name = "GOA bank acc " + suffix
code, body = http_json(
"POST",
f"{BANK}/accounts",