Module: Cryptoprocessing::Client::Transactions

Included in:
Cryptoprocessing::Client
Defined in:
lib/cryptoprocessing/client/transactions.rb

Overview

Constant Summary collapse

TRANSACTION_SEND_TYPE =
'send'
TRANSACTION_SEND_TYPE_RAW =
'sendraw'
TRANSACTION_FEE_FASTEST =
'fastestFee'
TRANSACTION_FEE_HALF_HOUR =
'halfHourFee'
TRANSACTION_FEE_HOUR =
'hourFee'

Instance Method Summary collapse

Instance Method Details

#create_transaction(account_id, options = {}) ⇒ Cryptoprocessing::Transaction

Create transaction

Создаем транзакцию



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/cryptoprocessing/client/transactions.rb', line 73

def create_transaction(, options = {})
  out = nil
  currency = if options[:currency] then options[:currency] else blockchain_type end
  options[:type] = TRANSACTION_SEND_TYPE
  options[:fee] = options[:fee] || TRANSACTION_FEE_FASTEST
  options[:from_] = options[:from]
  options[:to_] = options[:to]
  options.delete(:from)
  options.delete(:to)
  post("/v1/#{currency}/accounts/#{}/transactions", options) do |resp|
    out = Cryptoprocessing::Transaction.new(self, resp.data.merge(options))
    yield(out, resp) if block_given?
  end
  out
end

#send_raw_transaction(raw_transaction_id, options = {}) ⇒ Cryptoprocessing::Transaction

Send raw transaction signed transaction to the blockchain

Отсылаем в блокчейн сырую подписанную транзакцию



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/cryptoprocessing/client/transactions.rb', line 54

def send_raw_transaction(raw_transaction_id, options = {})
  out = nil
  currency = if options[:currency] then options[:currency] else blockchain_type end
  options[:type] = TRANSACTION_SEND_TYPE_RAW
  options[:raw_transaction_id] = raw_transaction_id
  post("/v1/#{currency}/sendrawtx", options) do |resp|
    out = Cryptoprocessing::Transaction.new(self, resp.data.merge(options))
    yield(out, resp) if block_given?
  end
  out
end

#transactions(account_id, options = {}) ⇒ Array<Cryptoprocessing::Transaction>

List transactions

список транзакций

Parameters:

  • account_id (String)

Returns:

See Also:



21
22
23
24
25
26
27
28
29
# File 'lib/cryptoprocessing/client/transactions.rb', line 21

def transactions(, options = {})
  out = nil
  currency = if options[:currency] then options[:currency] else blockchain_type end
  get("/v1/#{currency}/accounts/#{}/transactions", options) do |resp|
    out = resp.data['transactions'].map { |item| Cryptoprocessing::Transaction.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end

#transactions_by_address(account_id, address, options = {}) ⇒ Array<Cryptoprocessing::Transaction>

List transactions filtered by address

Parameters:

  • account_id (String)
  • address (String)

Returns:

See Also:



37
38
39
40
41
42
43
44
45
# File 'lib/cryptoprocessing/client/transactions.rb', line 37

def transactions_by_address(, address, options = {})
  out = nil
  currency = if options[:currency] then options[:currency] else blockchain_type end
  get("/v1/#{currency}/accounts/#{}/transactions/address/#{address}", options) do |resp|
    out = resp.data.map { |item| Cryptoprocessing::Transaction.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end