我正在使用他们拥有的红宝石宝石: https://github.com/coinbase/coinbase-ruby/tree/4.2.1
这是我成功使用api密钥获取主帐户后尝试使用其付款的错误:
account.request(to: 'example@example.com', amount: '0.00001', currency: 'BTC')
Traceback (most recent call last):
10: from /usr/share/rvm/rubies/ruby-2.6.4/bin/irb:23:in `<main>'
9: from /usr/share/rvm/rubies/ruby-2.6.4/bin/irb:23:in `load'
8: from /usr/share/rvm/rubies/ruby-2.6.4/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
7: from (irb):13
6: from (irb):13:in `rescue in irb_binding'
5: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/models/account.rb:79:in `request'
4: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb:302:in `request'
3: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb:687:in `post'
2: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/adapters/net_http.rb:36:in `http_verb'
1: from /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_errors.rb:28:in `check_response_status'
Coinbase::Wallet::ParamRequiredError (Missing parameter: `type`)
我遇到了byebug,当我遇到gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb:302:in
request'`方法时:
def request(account_id, params = {})
[ :to, :amount, :currency ].each do |param|
raise APIError, "Missing parameter: #{param}" unless params.include? param
end
params['type'] = 'request'
out = nil
post("/v2/accounts/#{account_id}/transactions", params) do |resp|
out = Request.new(self, resp.data)
yield(out, resp) if block_given?
end
out
end
我在请求中添加了“类型”参数。因此,我不确定此错误来自何处以及我将如何做下去。任何见识将不胜感激。
编辑: 注销并检查byebug:
byebug; account.request(to: 'example@example.com', amount: '0.00001', currency: 'BTC')
[74, 83] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/models/account.rb
74: yield(data, resp) if block_given?
75: end
76: end
77:
78: def request(params = {})
=> 79: @client.request(self['id'], params) do |data, resp|
80: yield(data, resp) if block_given?
81: end
82: end
83:
(byebug) step
[291, 300] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
291: end
292: out
293: end
294:
295: def request(account_id, params = {})
=> 296: [ :to, :amount, :currency ].each do |param|
297: raise APIError, "Missing parameter: #{param}" unless params.include? param
298: end
299: params['type'] = 'request'
300:
(byebug) eval params
{:to=>"example@example.com", :amount=>"0.00001", :currency=>"BTC"}
(byebug) step
[292, 301] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
292: out
293: end
294:
295: def request(account_id, params = {})
296: [ :to, :amount, :currency ].each do |param|
=> 297: raise APIError, "Missing parameter: #{param}" unless params.include? param
298: end
299: params['type'] = 'request'
300:
301: out = nil
(byebug)
[292, 301] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
292: out
293: end
294:
295: def request(account_id, params = {})
296: [ :to, :amount, :currency ].each do |param|
=> 297: raise APIError, "Missing parameter: #{param}" unless params.include? param
298: end
299: params['type'] = 'request'
300:
301: out = nil
(byebug)
[292, 301] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
292: out
293: end
294:
295: def request(account_id, params = {})
296: [ :to, :amount, :currency ].each do |param|
=> 297: raise APIError, "Missing parameter: #{param}" unless params.include? param
298: end
299: params['type'] = 'request'
300:
301: out = nil
(byebug)
[294, 303] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
294:
295: def request(account_id, params = {})
296: [ :to, :amount, :currency ].each do |param|
297: raise APIError, "Missing parameter: #{param}" unless params.include? param
298: end
=> 299: params['type'] = 'request'
300:
301: out = nil
302: post("/v2/accounts/#{account_id}/transactions", params) do |resp|
303: out = Request.new(self, resp.data)
(byebug)
[296, 305] in /home/doom/.rvm/gems/ruby-2.6.4/gems/coinbase-4.2.1/lib/coinbase/wallet/api_client.rb
296: [ :to, :amount, :currency ].each do |param|
297: raise APIError, "Missing parameter: #{param}" unless params.include? param
298: end
299: params['type'] = 'request'
300:
=> 301: post("/v2/accounts/#{account_id}/transactions", params) do |resp|
303: out = Request.new(self, resp.data)
304: yield(out, resp) if block_given?
305: end
(byebug) eval params
{:to=>"example@example.com", :amount=>"0.00001", :currency=>"BTC", "type"=>"request"} out = nil
302: post("/v2/accounts/#{account_id}/transactions", params) do |resp|
303: out = Request.new(self, resp.data)
304: yield(out, resp) if block_given?
305: end
(byebug) eval params
{:to=>"example@example.com", :amount=>"0.00001", :currency=>"BTC", "type"=>"request"}