获取账户中的所有用户钱包

Getting all user wallets in accounts

我在 Coinbase API 之上编写了便利的包装器。 要求之一是获取所有用户帐户。

使用适当的范围集并在 OAuth 身份验证成功后,我可以使用 /accounts端点。

但答案令人困惑:

{
"data": [
    {
        "id": "xxxx-xxxx-xxxx-xxxx",
        "name": "BTC Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "BTC",
            "name": "Bitcoin",
            "color": "#F7931A",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 100,
            "address_regex": "^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^(bc1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39}|[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{59}))$"
        },
        "balance": {
            "amount": "0.03115207",
            "currency": "BTC"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "ETC",
        "name": "ETC Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "ETC",
            "name": "Ethereum Classic",
            "color": "#59D4AF",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 103,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "ETC"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "ZRX",
        "name": "ZRX Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "ZRX",
            "name": "0x",
            "color": "#302C2C",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 105,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "ZRX"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "BAT",
        "name": "BAT Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "BAT",
            "name": "Basic Attention Token",
            "color": "#FF5000",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 106,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "BAT"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "USDC",
        "name": "USDC Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "USDC",
            "name": "USD Coin",
            "color": "#2775CA",
            "exponent": 6,
            "type": "crypto",
            "sort_index": 107,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.000000",
            "currency": "USDC"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "ZEC",
        "name": "ZEC Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "ZEC",
            "name": "Zcash",
            "color": "#ECB244",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 108,
            "address_regex": "^(t1|t3)[a-km-zA-HJ-NP-Z1-9]{33}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "ZEC"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "DAI",
        "name": "DAI Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "DAI",
            "name": "Dai",
            "color": "#FFB74D",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 115,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "DAI"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "LINK",
        "name": "LINK Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "LINK",
            "name": "Chainlink",
            "color": "#0667D0",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 122,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "LINK"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "XRP",
        "name": "XRP Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "XRP",
            "name": "XRP",
            "color": "#222222",
            "exponent": 6,
            "type": "crypto",
            "sort_index": 125,
            "address_regex": "^r[1-9a-km-zA-HJ-NP-Z]{25,35}$"
        },
        "balance": {
            "amount": "0.000000",
            "currency": "XRP"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "REP",
        "name": "REP Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "REP",
            "name": "Augur",
            "color": "#553580",
            "exponent": 8,
            "type": "crypto",
            "sort_index": 126,
            "address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
        },
        "balance": {
            "amount": "0.00000000",
            "currency": "REP"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    },
    {
        "id": "XLM",
        "name": "XLM Wallet",
        "primary": true,
        "type": "wallet",
        "currency": {
            "code": "XLM",
            "name": "Stellar Lumens",
            "color": "#000000",
            "exponent": 7,
            "type": "crypto",
            "sort_index": 127,
            "address_regex": "^G[A-Z2-7]{55}$"
        },
        "balance": {
            "amount": "0.0000000",
            "currency": "XLM"
        },
        "createdAt": null,
        "updatedAt": null,
        "resource": "account",
        "resourcePath": null
    }
]

端点returns 用户帐户列表不完整。我至少还有两个 coinbase accounts 余额不为零。

此外,id 不一致 - 对于 BTC,我们有某种 UUID,而其他钱包使用的是货币代码。

这使得 /transactions 端点请求为尝试指向不同于 BTC 钱包的请求返回 404: https://api.coinbase.com/v2/accounts/EOS/transactions.

知道如何获得完整的帐户列表,以及如何使用 BTC 钱包以外的 ID 吗?

我使用的示波器:

("wallet:accounts:read",
 "wallet:accounts:update",
 "wallet:transactions:read",
 "wallet:transactions:request",
 "wallet:transactions:send");

我向其中一个钱包添加了一笔交易,但它已从下一个 /accounts 请求中删除,这让它变得更加混乱。

经过一天的摸索,终于找到了答案。

在单个钱包的基础上附加帐户。

用户需要分别添加BTC、XRP、ETC等accounts/wallets。 每个接收到它自己的 TokenResponse 与访问和刷新令牌,您的应用程序需要管理。

仍然不明白在 /accounts 端点中返回不可用的剩余帐户的目的是什么 id

参考 Coinbase 文档https://developers.coinbase.com/docs/wallet/coinbase-connect/permissions

您可以将范围account = all添加到权限范围。这将为所有硬币启用读取权限

https://www.coinbase.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&account=all&redirect_uri=YOUR_CALLBACK_URL&scope=wallet:accounts:read,wallet:transactions:read