【问题标题】:Coinbase python APIError: Failed to send moneyCoinbase python APIError:汇款失败
【发布时间】:2015-03-28 08:05:37
【问题描述】:

我正在尝试集成新的Coinbase python library。我想让 send_money 工作。但不管我怎么试,它一直在说

transaction = account.send_money(address, bitcoins)
File "C:\Python27\lib\site-packages\coinbase\model.py", line 360, in send_money
'Failed to send money')
File "C:\Python27\lib\site-packages\coinbase\error.py", line 58, in build_api_error
raise error
APIError: Failed to send money

我的python代码:

bitcoins = 0.0001
# address = a bitcoin wallet address
client = Client(API_KEY, API_SECRET)
account = client.get_account()
transaction = account.send_money(address, str(bitcoins))

我可以检查我的余额,所以account 正在工作。此外,所有权限均在 Coinbase 网站的 API 设置中授予。

【问题讨论】:

    标签: python bitcoin coinbase-api


    【解决方案1】:

    您可能想查看错误的response 以了解调用失败的原因。这可能由于各种原因而发生,但错误消息应该会告诉您更多信息。

    https://github.com/coinbase/coinbase-python#error-handling

    from coinbase.error import CoinbaseError
    
    try:
        transaction = account.send_money(address, bitcoins)
    except CoinbaseError as e:
        print e.response.text
    

    【讨论】:

    • 你能告诉我如何获得responserequest 的值吗?我对 python 很陌生...
    • @Lancelot 我添加了一个示例。在您的代码中,您应该分别捕获不同的错误。有关所有错误,请参见 error.pygithub.com/coinbase/coinbase-python/blob/master/coinbase/…
    • 获取e.response.text 向我展示了更多细节。现在我已经解决了这个问题!谢谢@jorilallo
    猜你喜欢
    • 2020-12-16
    • 1970-01-01
    • 1970-01-01
    • 2016-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-31
    • 2013-07-16
    相关资源
    最近更新 更多