Class: Nis::Struct::Transaction
- Inherits:
-
Object
- Object
- Nis::Struct::Transaction
- Includes:
- Util::Assignable
- Defined in:
- lib/nis/struct/transaction.rb
Overview
Constant Summary collapse
- TRANSFER =
257 (transfer transaction)
0x0101- IMPORTANCE_TRANSFER =
2049 (importance transfer transaction)
0x0801- MULTISIG_AGGREGATE_MODIFICATION_TRANSFER =
4097 (multisig aggregate modification transfer transaction)
0x1001- MULTISIG_SIGNATURE =
4098 (multisig signature transaction)
0x1002- MULTISIG =
4099 (multisig transaction)
0x1004- PROVISION_NAMESPACE =
8193 (provision namespace transaction)
0x2001- MOSAIC_DEFINITION_CREATION =
16385 (mosaic definition creation transaction)
0x4001- MOSAIC_SUPPLY_CHANGE =
16386 (mosaic supply change transaction)
0x4002- TESTNET =
-1744830464
0x98000000- MAINNET =
1744830464
0x68000000- VERSION_1 =
1
0x00000001- VERSION_2 =
2
0x00000002- TESTNET_VERSION_1 =
0x98000001 = -1744830463
TESTNET | VERSION_1
- TESTNET_VERSION_2 =
0x98000002 = -1744830462
TESTNET | VERSION_2
- MAINNET_VERSION_1 =
0x68000001 = 1744830465
MAINNET | VERSION_1
- MAINNET_VERSION_2 =
0x68000002 = 1744830466
MAINNET | VERSION_2
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/transaction.rb', line 16 def amount @amount end |
#deadline ⇒ Integer
Returns the current value of deadline.
16 17 18 |
# File 'lib/nis/struct/transaction.rb', line 16 def deadline @deadline end |
#fee ⇒ Integer
16 17 18 |
# File 'lib/nis/struct/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/transaction.rb', line 16 def end |
#mosaics ⇒ Array <Nis::Struct::MosaicId>
Returns the current value of mosaics.
16 17 18 |
# File 'lib/nis/struct/transaction.rb', line 16 def mosaics @mosaics end |
#recipient ⇒ String
Returns the current value of recipient.
16 17 18 |
# File 'lib/nis/struct/transaction.rb', line 16 def recipient @recipient end |
#signer ⇒ String
Returns the current value of signer.
16 17 18 |
# File 'lib/nis/struct/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/transaction.rb', line 18 def timeStamp @timeStamp end |
#type ⇒ Integer
Returns the current value of type.
16 17 18 |
# File 'lib/nis/struct/transaction.rb', line 16 def type @type end |
#version ⇒ Integer
Returns the current value of version.
16 17 18 |
# File 'lib/nis/struct/transaction.rb', line 16 def version @version end |
Class Method Details
.build(attrs) ⇒ Object
44 45 46 |
# File 'lib/nis/struct/transaction.rb', line 44 def self.build(attrs) new(attrs) end |
Instance Method Details
#_version ⇒ Integer
49 50 51 |
# File 'lib/nis/struct/transaction.rb', line 49 def _version (0xFFFFFFF0 & @version) end |
#calculate_fee ⇒ Integer
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/nis/struct/transaction.rb', line 80 def calculate_fee if mosaics.empty? tmp_fee = [1, amount / 1_000_000 / 10000].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
59 60 61 |
# File 'lib/nis/struct/transaction.rb', line 59 def mainnet? (0x0000000F & @version) == MAINNET end |
#testnet? ⇒ Boolean
54 55 56 |
# File 'lib/nis/struct/transaction.rb', line 54 def testnet? (0x0000000F & @version) == TESTNET end |
#to_hash ⇒ Object
74 75 76 77 |
# File 'lib/nis/struct/transaction.rb', line 74 def to_hash fee to_hash_old end |
#to_hash_old ⇒ Object
72 |
# File 'lib/nis/struct/transaction.rb', line 72 alias to_hash_old to_hash |