Получение всех кошельков пользователей в аккаунтах

Я пишу удобную оболочку поверх 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 с ненулевым балансом.

Кроме того, идентификаторы несовместимы — для BTC у нас есть какой-то UUID, в то время как другие кошельки используют код валюты.

Это приводит к тому, что /transactions запросы конечных точек возвращают 404 для запросов, пытающихся указать на кошельки, отличные от BTC: https://api.coinbase.com/v2/accounts/EOS/transactions.

Любая идея, как получить полный список учетных записей, а также как работать с идентификатором для кошельков, отличных от BTC?

Прицелы, которые я использую:

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

Я добавил транзакцию в один из кошельков, а она была удалена из следующего /accounts запроса, что еще больше запутало.


person Patrick    schedule 24.07.2019    source источник


Ответы (2)


Ссылка на документацию 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
person Roshan    schedule 24.10.2019

После дня почесывания головы наконец нашел свой ответ.

Присоединение учетных записей происходит на основе одного кошелька.

Пользователю необходимо добавить учетные записи/кошельки BTC, XRP, ETC и т. д. отдельно. Каждый получает свой собственный TokenResponse с токеном доступа и обновления, которым должно управлять ваше приложение.

Еще не понял, в чем смысл возврата в /accounts конечной точке оставшихся аккаунтов с неиспользуемыми id.

person Patrick    schedule 25.07.2019