bank: funny auto-account name stems in withdraw API
This commit is contained in:
parent
7583d0896e
commit
e2e5c12f85
1 changed files with 40 additions and 10 deletions
|
|
@ -123,11 +123,42 @@ def mint_withdraw() -> dict:
|
|||
}
|
||||
|
||||
|
||||
def _rand_username() -> str:
|
||||
# Shown to the user: goa-account-<random> (bank-safe [a-z0-9-])
|
||||
# Funny stems for usernames / display names (bank-safe when lowercased)
|
||||
_FUNNY_STEMS = (
|
||||
"space-potato",
|
||||
"cosmic-slug",
|
||||
"nebula-nudge",
|
||||
"orbit-onion",
|
||||
"voidwave-vibe",
|
||||
"comet-crumb",
|
||||
"quark-quack",
|
||||
"plasma-pickle",
|
||||
"astro-bagel",
|
||||
"lunar-llama",
|
||||
"warp-waffle",
|
||||
"photon-pickle",
|
||||
"galaxy-gherkin",
|
||||
"rocket-raisin",
|
||||
"satellite-salsa",
|
||||
"meteor-muffin",
|
||||
"blackhole-burrito",
|
||||
"stardust-pretzel",
|
||||
"hyperdrive-hummus",
|
||||
"tachyonic-taco",
|
||||
)
|
||||
|
||||
|
||||
def _rand_username_and_name() -> tuple[str, str]:
|
||||
# Username: goa-account-<funny>-<short id> (shown to user)
|
||||
# Display name: Title Case funny phrase + id
|
||||
stem = secrets.choice(_FUNNY_STEMS)
|
||||
alphabet = string.ascii_lowercase + string.digits
|
||||
rnd = "".join(secrets.choice(alphabet) for _ in range(12))
|
||||
return "goa-account-" + rnd
|
||||
tag = "".join(secrets.choice(alphabet) for _ in range(5))
|
||||
username = f"goa-account-{stem}-{tag}"
|
||||
# human name: "Space Potato · k3m9x"
|
||||
pretty = " ".join(w.capitalize() for w in stem.split("-"))
|
||||
name = f"{pretty} · {tag}"
|
||||
return username, name
|
||||
|
||||
|
||||
def _rand_password() -> str:
|
||||
|
|
@ -140,10 +171,8 @@ def _rand_password() -> str:
|
|||
|
||||
def create_personal_account() -> dict:
|
||||
"""Public registration: auto username/password, balance starts at 0."""
|
||||
username = _rand_username()
|
||||
username, name = _rand_username_and_name()
|
||||
password = _rand_password()
|
||||
# Display name mirrors username for webui clarity
|
||||
name = username
|
||||
code, body = http_json(
|
||||
"POST",
|
||||
f"{BANK}/accounts",
|
||||
|
|
@ -156,8 +185,7 @@ def create_personal_account() -> dict:
|
|||
if code not in (200, 201, 204):
|
||||
# retry once on conflict
|
||||
if code in (409, 400):
|
||||
username = _rand_username()
|
||||
name = username
|
||||
username, name = _rand_username_and_name()
|
||||
code, body = http_json(
|
||||
"POST",
|
||||
f"{BANK}/accounts",
|
||||
|
|
@ -180,12 +208,14 @@ def create_personal_account() -> dict:
|
|||
"username": username,
|
||||
"password": password,
|
||||
"name": name,
|
||||
"display_name": name,
|
||||
"balance": "GOA:0",
|
||||
"balance_note": "Starts at zero — not the shared community pool.",
|
||||
"payto_uri": payto,
|
||||
"webui": "https://bank.hacktivism.ch/webui/",
|
||||
"hint": (
|
||||
"This bank account was created for you automatically. "
|
||||
"This bank account was created for you automatically "
|
||||
f"(funny name: {name}). "
|
||||
"Copy username and password now — we do not store them for later recovery. "
|
||||
"Balance starts at GOA:0."
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue