【问题标题】:Getting all user wallets in accounts获取账户中的所有用户钱包
【发布时间】:2019-12-02 07:34:05
【问题描述】:

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

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

但答案令人困惑:

{
"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
    }
]

端点返回不完整的用户帐户列表。我至少还有两个coinbase accounts 余额非零。

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

这使得 /transactions 端点请求返回 404,因为请求试图指向不同于 BTC 钱包的请求: 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 请求中删除,这使得它更加混乱。

【问题讨论】:

    标签: coinbase-api


    【解决方案1】:

    参考 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
    

    【讨论】:

      【解决方案2】:

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

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

      用户需要单独添加BTC、XRP、ETC等账户/钱包。 每个都收到自己的 TokenResponse 以及您的应用程序需要管理的访问和刷新令牌。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-10-09
        • 2023-01-27
        • 2022-05-31
        • 1970-01-01
        • 2019-03-29
        • 1970-01-01
        • 2022-09-23
        相关资源
        最近更新 更多