Class: Nem::Transaction::MultisigAggregateModification

Inherits:
Base
  • Object
show all
Defined in:
lib/nem/transaction/multisig_aggregate_modification.rb

Constant Summary collapse

TYPE =

4097 (multisig aggregate modification transfer transaction)

0x1001

Constants inherited from Base

Base::NETWORK

Instance Attribute Summary collapse

Attributes inherited from Base

#deadline, #fee, #signature, #signer, #timestamp, #type

Instance Method Summary collapse

Methods inherited from Base

#network

Constructor Details

#initialize(modifications, relative_change = 0, timestamp: nil, deadline: nil, network: nil) ⇒ MultisigAggregateModification

Returns a new instance of MultisigAggregateModification.



11
12
13
14
15
16
17
18
19
20
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 11

def initialize(modifications, relative_change = 0, timestamp: nil, deadline: nil, network: nil)
  @modifications = modifications
  @relative_change = relative_change

  @network = network || Nem.default_network
  @type = TYPE
  @fee = Nem::Fee::MultisigAggregateModification.new(self)
  @timestamp = timestamp || Time.now
  @deadline = deadline || Time.now + Nem.default_deadline
end

Instance Attribute Details

#min_cosignatoriesInterger

Returns the current value of min_cosignatories.

Returns:

  • (Interger)

    the current value of min_cosignatories



6
7
8
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 6

def min_cosignatories
  @min_cosignatories
end

#modificationsArray <Nem::Model::MultisigCosignatoryModification>

Returns the current value of modifications.

Returns:

  • (Array <Nem::Model::MultisigCosignatoryModification>)

    the current value of modifications



6
7
8
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 6

def modifications
  @modifications
end

#relative_changeInterger

Returns the current value of relative_change.

Returns:

  • (Interger)

    the current value of relative_change



6
7
8
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 6

def relative_change
  @relative_change
end

Instance Method Details

#has_relative_change?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 22

def has_relative_change?
  relative_change != 0
end

#to_hashHash

attributes must be CAMEL CASE for NIS params Modifications need to be sorted by address. if not it will occur FAILURE_SIGNATURE_NOT_VERIFIABLE

Returns:

  • (Hash)


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 34

def to_hash
  tmp = {
    minCosignatories: {
      relativeChange: relative_change
    }
  }
  tmp[:modifications] = modifications
    .sort_by { |mo| Nem::Unit::Address.from_public_key(mo.) }
    .map(&:to_hash)
  tmp
end

#versionObject



26
27
28
# File 'lib/nem/transaction/multisig_aggregate_modification.rb', line 26

def version
  network(hex: true) + (has_relative_change? ? 2 : 1)
end