Class: MixinBot::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/mixin_bot/transaction.rb,
lib/mixin_bot/transaction/buffer.rb,
lib/mixin_bot/transaction/decoder.rb,
lib/mixin_bot/transaction/encoder.rb

Defined Under Namespace

Classes: Buffer, Decoder, Encoder

Constant Summary collapse

REFERENCES_TX_VERSION =
0x04
SAFE_TX_VERSION =
0x05
DEAULT_VERSION =
5
MAGIC =
[0x77, 0x77].freeze
TX_VERSION =
2
MAX_ENCODE_INT =
0xFFFF
MAX_EXTRA_SIZE =
512
NULL_BYTES =
[0x00, 0x00].freeze
AGGREGATED_SIGNATURE_PREFIX =
0xFF01
AGGREGATED_SIGNATURE_ORDINAY_MASK =
[0x00].freeze
AGGREGATED_SIGNATURE_SPARSE_MASK =
[0x01].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Transaction

Returns a new instance of Transaction.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mixin_bot/transaction.rb', line 19

def initialize(**kwargs)
  @version = kwargs[:version] || DEAULT_VERSION
  @asset = kwargs[:asset]
  @inputs = kwargs[:inputs]
  @outputs = kwargs[:outputs]
  @extra = kwargs[:extra].to_s
  @hex = kwargs[:hex]
  @signatures = kwargs[:signatures]
  @aggregated = kwargs[:aggregated]
  @references = kwargs[:references]
end

Instance Attribute Details

#aggregatedObject

Returns the value of attribute aggregated.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def aggregated
  @aggregated
end

#assetObject

Returns the value of attribute asset.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def asset
  @asset
end

#extraObject

Returns the value of attribute extra.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def extra
  @extra
end

#hashObject

Returns the value of attribute hash.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def hash
  @hash
end

#hexObject

Returns the value of attribute hex.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def hex
  @hex
end

#inputsObject

Returns the value of attribute inputs.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def inputs
  @inputs
end

#outputsObject

Returns the value of attribute outputs.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def outputs
  @outputs
end

#referencesObject

Returns the value of attribute references.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def references
  @references
end

#signaturesObject

Returns the value of attribute signatures.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def signatures
  @signatures
end

#versionObject

Returns the value of attribute version.



17
18
19
# File 'lib/mixin_bot/transaction.rb', line 17

def version
  @version
end

Instance Method Details

#decodeObject



35
36
37
# File 'lib/mixin_bot/transaction.rb', line 35

def decode
  Decoder.new(self).decode
end

#encodeObject



31
32
33
# File 'lib/mixin_bot/transaction.rb', line 31

def encode
  Encoder.new(self).encode
end

#to_hObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mixin_bot/transaction.rb', line 39

def to_h
  {
    version:,
    asset:,
    inputs:,
    outputs:,
    extra:,
    signatures:,
    aggregated:,
    hash:,
    references:
  }.compact
end