Class: Nis::Struct::TransferTransaction
- Inherits:
-
Object
- Object
- Nis::Struct::TransferTransaction
- Includes:
- Util::Assignable
- Defined in:
- lib/nis/struct/transfer_transaction.rb
Overview
Constant Summary collapse
- TYPE =
257 (transfer transaction)
0x0101
Instance Attribute Summary collapse
-
#amount ⇒ Integer
The current value of amount.
-
#deadline ⇒ Integer
The current value of deadline.
- #fee ⇒ Integer
-
#message ⇒ Nis::Struct::Message
The current value of message.
-
#mosaics ⇒ Array <Nis::Struct::MosaicId>
The current value of mosaics.
-
#recipient ⇒ String
The current value of recipient.
-
#signer ⇒ String
The current value of signer.
-
#timeStamp ⇒ Object
(also: #timestamp)
Returns the value of attribute timeStamp.
-
#type ⇒ Integer
The current value of type.
-
#version ⇒ Integer
The current value of version.
Class Method Summary collapse
Instance Method Summary collapse
- #_version ⇒ Integer
- #calculate_fee ⇒ Integer
- #mainnet? ⇒ Boolean
- #testnet? ⇒ Boolean
- #to_hash ⇒ Object
- #to_hash_old ⇒ Object
Methods included from Util::Assignable
Instance Attribute Details
#amount ⇒ Integer
Returns the current value of amount.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def amount @amount end |
#deadline ⇒ Integer
Returns the current value of deadline.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def deadline @deadline end |
#fee ⇒ Integer
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def fee @fee end |
#message ⇒ Nis::Struct::Message
Returns the current value of message.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def @message end |
#mosaics ⇒ Array <Nis::Struct::MosaicId>
Returns the current value of mosaics.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def mosaics @mosaics end |
#recipient ⇒ String
Returns the current value of recipient.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def recipient @recipient end |
#signer ⇒ String
Returns the current value of signer.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def signer @signer end |
#timeStamp ⇒ Object Also known as: timestamp
Returns the value of attribute timeStamp.
18 19 20 |
# File 'lib/nis/struct/transfer_transaction.rb', line 18 def timeStamp @timeStamp end |
#type ⇒ Integer
Returns the current value of type.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def type @type end |
#version ⇒ Integer
Returns the current value of version.
16 17 18 |
# File 'lib/nis/struct/transfer_transaction.rb', line 16 def version @version end |
Class Method Details
.build(attrs) ⇒ Object
26 27 28 |
# File 'lib/nis/struct/transfer_transaction.rb', line 26 def self.build(attrs) new(attrs) end |
Instance Method Details
#_version ⇒ Integer
31 32 33 |
# File 'lib/nis/struct/transfer_transaction.rb', line 31 def _version (0xFFFFFFF0 & @version) end |
#calculate_fee ⇒ Integer
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/nis/struct/transfer_transaction.rb', line 62 def calculate_fee if mosaics.empty? tmp_fee = [1, amount / 1_000_000 / 10_000].max fee = (tmp_fee > 25 ? 25 : tmp_fee) else # TODO: calc mosaics fee raise NotImplementedError, 'not implemented calculation mosaic fee.' fee = 25 end if .bytesize > 0 fee += [1, (.bytesize / 2 / 32) + 1].max end fee * 1_000_000 end |
#mainnet? ⇒ Boolean
41 42 43 |
# File 'lib/nis/struct/transfer_transaction.rb', line 41 def mainnet? (0x0000000F & @version) == Nis::Util::MAINNET end |
#testnet? ⇒ Boolean
36 37 38 |
# File 'lib/nis/struct/transfer_transaction.rb', line 36 def testnet? (0x0000000F & @version) == Nis::Util::TESTNET end |
#to_hash ⇒ Object
56 57 58 59 |
# File 'lib/nis/struct/transfer_transaction.rb', line 56 def to_hash fee to_hash_old end |
#to_hash_old ⇒ Object
54 |
# File 'lib/nis/struct/transfer_transaction.rb', line 54 alias to_hash_old to_hash |