Class: Nis::Struct::TransferTransaction

Inherits:
Object
  • Object
show all
Includes:
Util::Assignable
Defined in:
lib/nis/struct/transfer_transaction.rb

Overview

Constant Summary collapse

TYPE =

257 (transfer transaction)

0x0101

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Assignable

#[], #initialize, #to_json

Instance Attribute Details

#amountInteger

Returns the current value of amount.

Returns:

  • (Integer)

    the current value of amount



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def amount
  @amount
end

#deadlineInteger

Returns the current value of deadline.

Returns:

  • (Integer)

    the current value of deadline



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def deadline
  @deadline
end

#feeInteger

Returns:

  • (Integer)


16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def fee
  @fee
end

#messageNis::Struct::Message

Returns the current value of message.

Returns:



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def message
  @message
end

#mosaicsArray <Nis::Struct::MosaicId>

Returns the current value of mosaics.

Returns:



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def mosaics
  @mosaics
end

#recipientString

Returns the current value of recipient.

Returns:

  • (String)

    the current value of recipient



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def recipient
  @recipient
end

#signerString

Returns the current value of signer.

Returns:

  • (String)

    the current value of signer



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def signer
  @signer
end

#timeStampObject 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

#typeInteger

Returns the current value of type.

Returns:

  • (Integer)

    the current value of type



16
17
18
# File 'lib/nis/struct/transfer_transaction.rb', line 16

def type
  @type
end

#versionInteger

Returns the current value of version.

Returns:

  • (Integer)

    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

#_versionInteger

Returns:

  • (Integer)


31
32
33
# File 'lib/nis/struct/transfer_transaction.rb', line 31

def _version
  (0xFFFFFFF0 & @version)
end

#calculate_feeInteger

Returns:

  • (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 message.bytesize > 0
    fee += [1, (message.bytesize / 2 / 32) + 1].max
  end

  fee * 1_000_000
end

#mainnet?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/nis/struct/transfer_transaction.rb', line 41

def mainnet?
  (0x0000000F & @version) == Nis::Util::MAINNET
end

#testnet?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/nis/struct/transfer_transaction.rb', line 36

def testnet?
  (0x0000000F & @version) == Nis::Util::TESTNET
end

#to_hashObject



56
57
58
59
# File 'lib/nis/struct/transfer_transaction.rb', line 56

def to_hash
  fee
  to_hash_old
end

#to_hash_oldObject



54
# File 'lib/nis/struct/transfer_transaction.rb', line 54

alias to_hash_old to_hash