帐户之间的Coinbase转移返回“未找到”

时间:2019-05-27 09:19:20

标签: node.js coinbase-api

我正在尝试在帐户之间转移BTC和BCH。查看文档,发现以下内容: https://developers.coinbase.com/api/v2#transfer-money-between-accounts

首先,我认为他们的示例中有错误,因为“ currency”属性是强制性的,因此在不提供该属性时会出错。

但是添加货币后,我发出的每个请求都以“未找到”返回。

我正在使用节点客户端,但是我认为问题更高。

这是我正在做的请求:

const Client        = require('coinbase').Client;

let client = new Client({'apiKey': 'xxxx', 'apiSecret': 'xxx'});

client.getAccounts({}, function(err, accounts) {

    let btc_account = null;
    let bch_account = null;

    for(account of accounts) {
        if(account.currency == "BTC") {
            btc_account = account;
        } else if(account.currency == "BCH") {
            bch_account = account;
        }
    }

    var options = {'to': bch_account.id, 'amount': btc_account.balance.amount, 'currency': "BTC"};

    btc_account.transferMoney(options, function(err, tx) {
        if(err) {
            console.log("ERROR during transfer", err);
            return
        }
        console.log(tx);
    });
});

这样做使我得到:

ERROR during transfer NotFound: Not found

进行一些调试之后,我发现它尝试使用以下选项来执行请求:

url: 'https://api.coinbase.com/v2/accounts/xxx/transactions'
body: '{"to":"xxx","amount":"0.00072256","currency":"BTC","type":"transfer"}'

(混淆了实际的account.id)

他们的API的实际响应是:

{"errors":[{"id":"not_found","message":"Not found"}]}

有人可以告诉我我在做什么错吗?

0 个答案:

没有答案