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:
|
# Funny stems for usernames / display names (bank-safe when lowercased)
|
||||||
# Shown to the user: goa-account-<random> (bank-safe [a-z0-9-])
|
_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
|
alphabet = string.ascii_lowercase + string.digits
|
||||||
rnd = "".join(secrets.choice(alphabet) for _ in range(12))
|
tag = "".join(secrets.choice(alphabet) for _ in range(5))
|
||||||
return "goa-account-" + rnd
|
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:
|
def _rand_password() -> str:
|
||||||
|
|
@ -140,10 +171,8 @@ def _rand_password() -> str:
|
||||||
|
|
||||||
def create_personal_account() -> dict:
|
def create_personal_account() -> dict:
|
||||||
"""Public registration: auto username/password, balance starts at 0."""
|
"""Public registration: auto username/password, balance starts at 0."""
|
||||||
username = _rand_username()
|
username, name = _rand_username_and_name()
|
||||||
password = _rand_password()
|
password = _rand_password()
|
||||||
# Display name mirrors username for webui clarity
|
|
||||||
name = username
|
|
||||||
code, body = http_json(
|
code, body = http_json(
|
||||||
"POST",
|
"POST",
|
||||||
f"{BANK}/accounts",
|
f"{BANK}/accounts",
|
||||||
|
|
@ -156,8 +185,7 @@ def create_personal_account() -> dict:
|
||||||
if code not in (200, 201, 204):
|
if code not in (200, 201, 204):
|
||||||
# retry once on conflict
|
# retry once on conflict
|
||||||
if code in (409, 400):
|
if code in (409, 400):
|
||||||
username = _rand_username()
|
username, name = _rand_username_and_name()
|
||||||
name = username
|
|
||||||
code, body = http_json(
|
code, body = http_json(
|
||||||
"POST",
|
"POST",
|
||||||
f"{BANK}/accounts",
|
f"{BANK}/accounts",
|
||||||
|
|
@ -180,12 +208,14 @@ def create_personal_account() -> dict:
|
||||||
"username": username,
|
"username": username,
|
||||||
"password": password,
|
"password": password,
|
||||||
"name": name,
|
"name": name,
|
||||||
|
"display_name": name,
|
||||||
"balance": "GOA:0",
|
"balance": "GOA:0",
|
||||||
"balance_note": "Starts at zero — not the shared community pool.",
|
"balance_note": "Starts at zero — not the shared community pool.",
|
||||||
"payto_uri": payto,
|
"payto_uri": payto,
|
||||||
"webui": "https://bank.hacktivism.ch/webui/",
|
"webui": "https://bank.hacktivism.ch/webui/",
|
||||||
"hint": (
|
"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. "
|
"Copy username and password now — we do not store them for later recovery. "
|
||||||
"Balance starts at GOA:0."
|
"Balance starts at GOA:0."
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue