bank: auto usernames goa-account-<random> shown to user

API and docs describe the visible auto username shape.
This commit is contained in:
Hernâni Marques 2026-07-10 15:43:00 +02:00
parent 2519c8844b
commit 7583d0896e
No known key found for this signature in database
3 changed files with 10 additions and 9 deletions

View file

@ -124,8 +124,10 @@ def mint_withdraw() -> dict:
def _rand_username() -> str:
# goa-bank-acc-<uuid> — unique guest id, bank-safe [a-z0-9-]
return "goa-bank-acc-" + secrets.token_hex(8)
# Shown to the user: goa-account-<random> (bank-safe [a-z0-9-])
alphabet = string.ascii_lowercase + string.digits
rnd = "".join(secrets.choice(alphabet) for _ in range(12))
return "goa-account-" + rnd
def _rand_password() -> str:
@ -140,9 +142,8 @@ def create_personal_account() -> dict:
"""Public registration: auto username/password, balance starts at 0."""
username = _rand_username()
password = _rand_password()
# short label from id suffix
suffix = username.rsplit("-", 1)[-1][:8]
name = "GOA bank acc " + suffix
# Display name mirrors username for webui clarity
name = username
code, body = http_json(
"POST",
f"{BANK}/accounts",
@ -156,8 +157,7 @@ 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
name = username
code, body = http_json(
"POST",
f"{BANK}/accounts",