Show TRC20 USDT pay address on the license page.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,7 +14,10 @@ from lib.license.license_lib import (
|
|||||||
get_license_status,
|
get_license_status,
|
||||||
is_license_valid,
|
is_license_valid,
|
||||||
redeem_code,
|
redeem_code,
|
||||||
|
usdt_address,
|
||||||
|
usdt_network,
|
||||||
validate_license,
|
validate_license,
|
||||||
|
wechat_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
_TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "license.html"
|
_TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "license.html"
|
||||||
@@ -133,7 +136,9 @@ def install_license_middleware(app: FastAPI) -> None:
|
|||||||
filled = (
|
filled = (
|
||||||
html.replace("{{ device_id }}", get_device_id())
|
html.replace("{{ device_id }}", get_device_id())
|
||||||
.replace("{{ api_url }}", str(status.get("api_url") or ""))
|
.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("{{ message }}", msg)
|
||||||
.replace("{{ error }}", err)
|
.replace("{{ error }}", err)
|
||||||
.replace("{{ status_message }}", str(status.get("message") or ""))
|
.replace("{{ status_message }}", str(status.get("message") or ""))
|
||||||
@@ -150,7 +155,9 @@ def install_license_middleware(app: FastAPI) -> None:
|
|||||||
message=msg,
|
message=msg,
|
||||||
error=err,
|
error=err,
|
||||||
api_url=status.get("api_url") or "",
|
api_url=status.get("api_url") or "",
|
||||||
wechat="dekun03",
|
wechat=wechat_id(),
|
||||||
|
usdt_address=usdt_address(),
|
||||||
|
usdt_network=usdt_network(),
|
||||||
)
|
)
|
||||||
return HTMLResponse(filled)
|
return HTMLResponse(filled)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ from lib.license.license_lib import (
|
|||||||
get_license_status,
|
get_license_status,
|
||||||
is_license_valid,
|
is_license_valid,
|
||||||
redeem_code,
|
redeem_code,
|
||||||
|
usdt_address,
|
||||||
|
usdt_network,
|
||||||
validate_license,
|
validate_license,
|
||||||
|
wechat_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
_TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "license.html"
|
_TEMPLATE_PATH = Path(__file__).resolve().parent / "templates" / "license.html"
|
||||||
@@ -137,7 +140,9 @@ def install_license_gate(app: Flask) -> None:
|
|||||||
message=msg,
|
message=msg,
|
||||||
error=err,
|
error=err,
|
||||||
api_url=status.get("api_url") or "",
|
api_url=status.get("api_url") or "",
|
||||||
wechat="dekun03",
|
wechat=wechat_id(),
|
||||||
|
usdt_address=usdt_address(),
|
||||||
|
usdt_network=usdt_network(),
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ DEFAULT_OFFLINE_GRACE_HOURS = 72
|
|||||||
STATE_FILENAME = "license_state.json"
|
STATE_FILENAME = "license_state.json"
|
||||||
LICENSE_ENV_NAME = "license.env"
|
LICENSE_ENV_NAME = "license.env"
|
||||||
|
|
||||||
|
# USDT 收款(与授权站 app/plans.py 保持一致;可用环境变量覆盖)
|
||||||
|
DEFAULT_USDT_ADDRESS = "TEqtozJKTEJ6qZcyvienpfyswaeAHXc8ks"
|
||||||
|
DEFAULT_USDT_NETWORK = "TRC20"
|
||||||
|
DEFAULT_WECHAT_ID = "dekun03"
|
||||||
|
|
||||||
_lock = threading.RLock()
|
_lock = threading.RLock()
|
||||||
_cached_device_id: str | None = None
|
_cached_device_id: str | None = None
|
||||||
_env_loaded = False
|
_env_loaded = False
|
||||||
@@ -61,6 +66,21 @@ def api_base_url() -> str:
|
|||||||
return url or DEFAULT_API_URL
|
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:
|
def client_key() -> str:
|
||||||
_load_license_env()
|
_load_license_env()
|
||||||
env_key = (os.getenv("LICENSE_CLIENT_KEY") or "").strip()
|
env_key = (os.getenv("LICENSE_CLIENT_KEY") or "").strip()
|
||||||
|
|||||||
@@ -43,6 +43,24 @@
|
|||||||
font-family: ui-monospace, Consolas, monospace;
|
font-family: ui-monospace, Consolas, monospace;
|
||||||
font-size: 0.85rem;
|
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] {
|
input[type=text], input[type=password] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 10px 12px;
|
padding: 10px 12px;
|
||||||
@@ -75,6 +93,17 @@
|
|||||||
<h1>软件授权</h1>
|
<h1>软件授权</h1>
|
||||||
<p class="muted">复制设备 ID,联系微信 <strong>{{ wechat }}</strong> 获取 <strong>客户密钥</strong> 与激活码。授权站:{{ api_url }}</p>
|
<p class="muted">复制设备 ID,联系微信 <strong>{{ wechat }}</strong> 获取 <strong>客户密钥</strong> 与激活码。授权站:{{ api_url }}</p>
|
||||||
|
|
||||||
|
{% if usdt_address %}
|
||||||
|
<div class="pay-box">
|
||||||
|
<div class="pay-title">USDT 收款地址({{ usdt_network or 'TRC20' }})</div>
|
||||||
|
<div class="pay-row">
|
||||||
|
<div class="id" id="usdtAddress">{{ usdt_address }}</div>
|
||||||
|
<button type="button" id="copyUsdtBtn">复制</button>
|
||||||
|
</div>
|
||||||
|
<div class="hint">仅支持 {{ usdt_network or 'TRC20' }} 网络,转错链无法找回。年卡 1000 USDT + 部署费 100 USDT。</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if message %}<p class="ok">{{ message }}</p>{% endif %}
|
{% if message %}<p class="ok">{{ message }}</p>{% endif %}
|
||||||
{% if error %}<p class="err">{{ error }}</p>{% endif %}
|
{% if error %}<p class="err">{{ error }}</p>{% endif %}
|
||||||
|
|
||||||
@@ -102,5 +131,28 @@
|
|||||||
套餐:{{ status.plan or '—' }} 到期:{{ status.expires_at or '—' }}
|
套餐:{{ status.plan or '—' }} 到期:{{ status.expires_at or '—' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
var btn = document.getElementById("copyUsdtBtn");
|
||||||
|
var el = document.getElementById("usdtAddress");
|
||||||
|
if (!btn || !el) return;
|
||||||
|
btn.addEventListener("click", function () {
|
||||||
|
var text = (el.textContent || "").trim();
|
||||||
|
if (!text) return;
|
||||||
|
var done = function () {
|
||||||
|
var old = btn.textContent;
|
||||||
|
btn.textContent = "已复制";
|
||||||
|
setTimeout(function () { btn.textContent = old; }, 1500);
|
||||||
|
};
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(text).then(done).catch(function () {
|
||||||
|
window.prompt("复制地址", text);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.prompt("复制地址", text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user