Class: Keoken::Backend::Trezor::Transaction
- Defined in:
- lib/keoken/backend/trezor/transaction.rb
Instance Attribute Summary collapse
-
#to_json ⇒ Object
Returns the value of attribute to_json.
Attributes inherited from Base
#bitprim_transaction, #inputs, #tokens, #total_inputs_amount
Instance Method Summary collapse
-
#build_for_creation(address, path, script, xpubs = []) ⇒ Keoken::Backend::Trezor::Transaction
Create the transaction to broadcast in order to create tokens.
-
#build_for_empty_wallet(addresses, address_dest, path, xpubs = []) ⇒ Keoken::Backend::Trezor::Transaction
Create the transaction to broadcast in order to empty the wallet.
-
#build_for_send_amount(address, address_dest, path, script, xpubs = []) ⇒ Keoken::Backend::Trezor::Transaction
Create the transaction to broadcast in order to send amount between tokens.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Keoken::Backend::Base
Instance Attribute Details
#to_json ⇒ Object
Returns the value of attribute to_json.
7 8 9 |
# File 'lib/keoken/backend/trezor/transaction.rb', line 7 def to_json @to_json end |
Instance Method Details
#build_for_creation(address, path, script, xpubs = []) ⇒ Keoken::Backend::Trezor::Transaction
Create the transaction to broadcast in order to create tokens.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/keoken/backend/trezor/transaction.rb', line 18 def build_for_creation(address, path, script, xpubs = []) build_inputs([address]) total, fee = build_fee(:create) output_amount = total - fee.to_i create(inputs: @inputs, path: path, address: address, output_amount: output_amount, script: script, xpubs: xpubs) end |
#build_for_empty_wallet(addresses, address_dest, path, xpubs = []) ⇒ Keoken::Backend::Trezor::Transaction
Create the transaction to broadcast in order to empty the wallet.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/keoken/backend/trezor/transaction.rb', line 64 def build_for_empty_wallet(addresses, address_dest, path, xpubs = []) build_inputs(addresses) total, fee = build_fee(:send) raise Keoken::Error::NoToken if @tokens.empty? send(inputs: @inputs, path: path, output_amount: total - (fee.to_i * 2), address: nil, output_amount_to_addr2: fee.to_i, addr2: address_dest, script: token_script_for_inputs, xpubs: xpubs) end |
#build_for_send_amount(address, address_dest, path, script, xpubs = []) ⇒ Keoken::Backend::Trezor::Transaction
Create the transaction to broadcast in order to send amount between tokens.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/keoken/backend/trezor/transaction.rb', line 40 def build_for_send_amount(address, address_dest, path, script, xpubs = []) build_inputs([address]) total, fee = build_fee(:send) output_amount = total - (fee.to_i * 2) output_amount_to_addr2 = fee.to_i send(inputs: @inputs, path: path, output_amount: output_amount, address: address, output_amount_to_addr2: output_amount_to_addr2, addr2: address_dest, script: script, xpubs: xpubs) end |