From 4fe0df6c6d5d9c5787445821651b2e9db4eb5141 Mon Sep 17 00:00:00 2001 From: dekun Date: Fri, 17 Jul 2026 20:12:09 +0800 Subject: [PATCH] Show TRC20 USDT pay address on the license page. Co-authored-by: Cursor --- lib/license/fastapi_gate.py | 11 +++++-- lib/license/flask_gate.py | 7 +++- lib/license/license_lib.py | 20 ++++++++++++ lib/license/templates/license.html | 52 ++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 3 deletions(-) diff --git a/lib/license/fastapi_gate.py b/lib/license/fastapi_gate.py index a020fb8..f845c9e 100644 --- a/lib/license/fastapi_gate.py +++ b/lib/license/fastapi_gate.py @@ -14,7 +14,10 @@ from lib.license.license_lib import ( get_license_status, is_license_valid, redeem_code, + usdt_address, + usdt_network, validate_license, + wechat_id, ) _TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "license.html" @@ -133,7 +136,9 @@ def install_license_middleware(app: FastAPI) -> None: filled = ( html.replace("{{ device_id }}", get_device_id()) .replace("{{ api_url }}", str(status.get("api_url") or "")) - .replace("{{ wechat }}", "dekun03") + .replace("{{ wechat }}", wechat_id()) + .replace("{{ usdt_address }}", usdt_address()) + .replace("{{ usdt_network }}", usdt_network()) .replace("{{ message }}", msg) .replace("{{ error }}", err) .replace("{{ status_message }}", str(status.get("message") or "")) @@ -150,7 +155,9 @@ def install_license_middleware(app: FastAPI) -> None: message=msg, error=err, api_url=status.get("api_url") or "", - wechat="dekun03", + wechat=wechat_id(), + usdt_address=usdt_address(), + usdt_network=usdt_network(), ) return HTMLResponse(filled) diff --git a/lib/license/flask_gate.py b/lib/license/flask_gate.py index 9648b7b..584bcbc 100644 --- a/lib/license/flask_gate.py +++ b/lib/license/flask_gate.py @@ -13,7 +13,10 @@ from lib.license.license_lib import ( get_license_status, is_license_valid, redeem_code, + usdt_address, + usdt_network, validate_license, + wechat_id, ) _TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "license.html" @@ -137,7 +140,9 @@ def install_license_gate(app: Flask) -> None: message=msg, error=err, api_url=status.get("api_url") or "", - wechat="dekun03", + wechat=wechat_id(), + usdt_address=usdt_address(), + usdt_network=usdt_network(), ) @app.before_request diff --git a/lib/license/license_lib.py b/lib/license/license_lib.py index c0794ef..60f4d6f 100644 --- a/lib/license/license_lib.py +++ b/lib/license/license_lib.py @@ -23,6 +23,11 @@ DEFAULT_OFFLINE_GRACE_HOURS = 72 STATE_FILENAME = "license_state.json" LICENSE_ENV_NAME = "license.env" +# USDT 收款(与授权站 app/plans.py 保持一致;可用环境变量覆盖) +DEFAULT_USDT_ADDRESS = "TEqtozJKTEJ6qZcyvienpfyswaeAHXc8ks" +DEFAULT_USDT_NETWORK = "TRC20" +DEFAULT_WECHAT_ID = "dekun03" + _lock = threading.RLock() _cached_device_id: str | None = None _env_loaded = False @@ -61,6 +66,21 @@ def api_base_url() -> str: return url or DEFAULT_API_URL +def usdt_address() -> str: + _load_license_env() + return (os.getenv("LICENSE_USDT_ADDRESS") or DEFAULT_USDT_ADDRESS).strip() + + +def usdt_network() -> str: + _load_license_env() + return (os.getenv("LICENSE_USDT_NETWORK") or DEFAULT_USDT_NETWORK).strip() or DEFAULT_USDT_NETWORK + + +def wechat_id() -> str: + _load_license_env() + return (os.getenv("LICENSE_WECHAT_ID") or DEFAULT_WECHAT_ID).strip() or DEFAULT_WECHAT_ID + + def client_key() -> str: _load_license_env() env_key = (os.getenv("LICENSE_CLIENT_KEY") or "").strip() diff --git a/lib/license/templates/license.html b/lib/license/templates/license.html index f2dc0e2..0ef209c 100644 --- a/lib/license/templates/license.html +++ b/lib/license/templates/license.html @@ -43,6 +43,24 @@ font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; } + .pay-box { + margin-bottom: 16px; + padding: 12px; + border-radius: 10px; + border: 1px solid #2a3a2a; + background: #0e1610; + } + .pay-box .pay-title { font-size: 0.85rem; color: #9fe0b8; margin-bottom: 8px; } + .pay-row { display: flex; gap: 8px; align-items: stretch; } + .pay-row .id { flex: 1; } + .pay-row button { + width: auto; + margin: 0; + padding: 8px 12px; + flex-shrink: 0; + background: #2a4a36; + font-size: 0.85rem; + } input[type=text], input[type=password] { width: 100%; padding: 10px 12px; @@ -75,6 +93,17 @@

软件授权

复制设备 ID,联系微信 {{ wechat }} 获取 客户密钥 与激活码。授权站:{{ api_url }}

+ {% if usdt_address %} +
+
USDT 收款地址({{ usdt_network or 'TRC20' }})
+
+
{{ usdt_address }}
+ +
+
仅支持 {{ usdt_network or 'TRC20' }} 网络,转错链无法找回。年卡 1000 USDT + 部署费 100 USDT。
+
+ {% endif %} + {% if message %}

{{ message }}

{% endif %} {% if error %}

{{ error }}

{% endif %} @@ -102,5 +131,28 @@ 套餐:{{ status.plan or '—' }} 到期:{{ status.expires_at or '—' }} +