探针把 40014 判为最小权限的正常表现,并翻译 parentId/权限/白名单

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jack
2026-08-28 18:36:10 +08:00
co-authored by Cursor
parent f62b4f62a5
commit 668ebe1e44
+33 -7
View File
@@ -29,6 +29,20 @@ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from bitget_rest import MARGIN_COIN, PRODUCT, Bitget # noqa: E402
def _perm_hint(e: Exception) -> str:
"""把 40014 说成"正常"而不是"故障"
这把 key 刻意只开合约权限,所以现货类端点必然报 40014。**不要**为了让
这个探针看全就去加现货权限——那是白扩爆炸半径,而同样的信息在 App 里
看一眼就有。
"""
s = str(e)
if "40014" in s:
return ("跳过:这把 key 没开现货权限(刻意的,最小权限)。"
"这一栏改用 Bitget App 看,别为了探针去加权限")
return f"查不了:{type(e).__name__}: {e}"
async def main() -> None:
api = Bitget()
if not (api.key and api.secret and api.passphrase):
@@ -41,7 +55,7 @@ async def main() -> None:
flag = " ← 钱在这里" if amt > 1 else ""
print(f" {b.get('accountType'):<16} {amt:>12.2f} USDT{flag}")
except Exception as e: # noqa: BLE001
print(f" 查不了:{type(e).__name__}: {e}")
print(f" {_perm_hint(e)}")
print(f"\n── {PRODUCT} 下的各保证金币种 ──")
try:
@@ -53,7 +67,7 @@ async def main() -> None:
print(f" {a.get('marginCoin'):<8} 权益 {eq:>12.4f} · "
f"可用 {float(a.get('available') or 0):>12.4f}")
except Exception as e: # noqa: BLE001
print(f" 查不了:{type(e).__name__}: {e}")
print(f" {_perm_hint(e)}")
print("\n── 其他合约类型(钱可能充错了本位)──")
for pt in ("coin-futures", "usdc-futures"):
@@ -74,16 +88,28 @@ async def main() -> None:
print(f" {hit if hit else ''}"
f"{' ← 要划转到 U 本位合约' if hit else ''}")
except Exception as e: # noqa: BLE001
print(f" 查不了:{type(e).__name__}: {e}")
print(f" {_perm_hint(e)}")
print("\n── 这把 key 属于哪个账户 ──")
for path in ("/api/v2/user/account-info", "/api/v2/spot/account/info"):
for path in ("/api/v2/spot/account/info", "/api/v2/user/account-info"):
try:
d = await api._req("GET", path)
print(f" {path}{d}")
break
d = await api._req("GET", path) or {}
except Exception as e: # noqa: BLE001
print(f" {path} 查不了:{type(e).__name__}: {e}")
continue
uid, par = d.get("userId"), d.get("parentId")
print(f" userId {uid}")
if par:
print(f" parentId {par} → **这是子账户**。主账户的钱这把 key"
f" 看不到也动不了,这是好事(爆炸半径被账户边界封住)。"
f"\n 但充值要充到 userId {uid} 的 U 本位合约里。"
f"\n 注意主→子划转默认落在子账户的**现货**钱包,"
f"还要在子账户内部再划一次到 U 本位合约")
else:
print(" 没有 parentId → 这是主账户")
print(f" 权限 {d.get('authorities')}(没有现货权限是刻意的)")
print(f" IP 白名单 {d.get('ips')}")
break
finally:
await api.close()