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
-
#create_transaction(account_id, options = {}) ⇒ Cryptoprocessing::Transaction
Create transaction.
-
#send_raw_transaction(raw_transaction_id, options = {}) ⇒ Cryptoprocessing::Transaction
Send raw transaction signed transaction to the blockchain.
-
#transactions(account_id, options = {}) ⇒ Array<Cryptoprocessing::Transaction>
List transactions.
-
#transactions_by_address(account_id, address, options = {}) ⇒ Array<Cryptoprocessing::Transaction>
List transactions filtered by address.
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(account_id, = {}) out = nil currency = if [:currency] then [:currency] else blockchain_type end [:type] = TRANSACTION_SEND_TYPE [:fee] = [:fee] || TRANSACTION_FEE_FASTEST [:from_] = [:from] [:to_] = [:to] .delete(:from) .delete(:to) post("/v1/#{currency}/accounts/#{account_id}/transactions", ) do |resp| out = Cryptoprocessing::Transaction.new(self, resp.data.merge()) 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, = {}) out = nil currency = if [:currency] then [:currency] else blockchain_type end [:type] = TRANSACTION_SEND_TYPE_RAW [:raw_transaction_id] = raw_transaction_id post("/v1/#{currency}/sendrawtx", ) do |resp| out = Cryptoprocessing::Transaction.new(self, resp.data.merge()) yield(out, resp) if block_given? end out end |
#transactions(account_id, options = {}) ⇒ Array<Cryptoprocessing::Transaction>
List transactions
список транзакций
21 22 23 24 25 26 27 28 29 |
# File 'lib/cryptoprocessing/client/transactions.rb', line 21 def transactions(account_id, = {}) out = nil currency = if [:currency] then [:currency] else blockchain_type end get("/v1/#{currency}/accounts/#{account_id}/transactions", ) 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
37 38 39 40 41 42 43 44 45 |
# File 'lib/cryptoprocessing/client/transactions.rb', line 37 def transactions_by_address(account_id, address, = {}) out = nil currency = if [:currency] then [:currency] else blockchain_type end get("/v1/#{currency}/accounts/#{account_id}/transactions/address/#{address}", ) do |resp| out = resp.data.map { |item| Cryptoprocessing::Transaction.new(self, item) } yield(out, resp) if block_given? end out end |