class GarnetClient::Service

Public Class Methods

tx_get_info(coin_type, tx_id) click to toggle source

查询转账明细

# File lib/garnet_client/service.rb, line 41
def self.tx_get_info(coin_type, tx_id)
  service_path = "/tx/#{coin_type}/#{tx_id}"

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_get(service_path)
  msg
end
tx_transfer(coin_type, source_id, from, to, value) click to toggle source

发送一笔转账

# File lib/garnet_client/service.rb, line 25
def self.tx_transfer(coin_type, source_id, from, to, value)
  service_path = "/tx/#{coin_type}/transfer"
  from_address = from.nil? ? '' : from
  post_params = {
      "source_id" => source_id,
      "from" => from_address,
      "to" => to,
      "value" => value
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end
wallet_get_balance(coin_type, address) click to toggle source

查询余额

# File lib/garnet_client/service.rb, line 16
def self.wallet_get_balance(coin_type, address)
  service_path = "/wallet/#{coin_type}/balance/#{address}"

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_get(service_path)
  msg
end
wallet_get_or_create_address(coin_type, user_id) click to toggle source

获得一个地址

# File lib/garnet_client/service.rb, line 4
def self.wallet_get_or_create_address(coin_type, user_id)
  service_path = "/wallet/#{coin_type}/get_or_create_address"
  post_params = {
      "user_id" => user_id
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end
wallet_import_key(file_name, address, key_data, key_pwd, user_id) click to toggle source

import钱包

# File lib/garnet_client/service.rb, line 67
def self.wallet_import_key(file_name, address, key_data, key_pwd, user_id)
  service_path = "/wallet/eth/import_key"
  post_params = {
      "file_name" => file_name,
      "address" => address,
      "key_data" => key_data,
      "key_pwd" => key_pwd,
      "user_id" => user_id
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end
withdraw_create_order(user_id, to, coin_type, value, transfer_fee, description) click to toggle source

提交提现单

# File lib/garnet_client/service.rb, line 50
def self.withdraw_create_order(user_id, to, coin_type, value, transfer_fee, description)
  service_path = "/withdraw/submit_order"
  post_params = {
      "user_id" => user_id,
      "to" => to,
      "coin_type" => coin_type,
      "value" => value,
      "transfer_fee" => transfer_fee,
      "description" => description
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end