Class: Sigma::ReducedTransaction

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/reduced_transaction.rb

Overview

Represent ‘reduced` transaction, i.e. unsigned transaction where each unsigned input is augmented with ReducedInput which contains a script reduction result. After an unsigned transaction is reduced it can be signed without context. Thus, it can be serialized and transferred for example to Cold Wallet and signed in an environment where secrets are known. see EIP-19 for more details

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



20
21
22
# File 'lib/sigma/reduced_transaction.rb', line 20

def pointer
  @pointer
end

Class Method Details

.from_unsigned_tx(unsigned_tx:, boxes_to_spend:, data_boxes:, state_context:) ⇒ ReducedTransaction

Create ‘reduced` transaction, i.e. unsigned transaction where each unsigned input is augmented with ReducedInput which contains a script reduction result.

Parameters:

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sigma/reduced_transaction.rb', line 29

def self.from_unsigned_tx(unsigned_tx:, boxes_to_spend:, data_boxes:, state_context:)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_reduced_tx_from_unsigned_tx(
      unsigned_tx.pointer,
      boxes_to_spend.pointer,
      data_boxes.pointer,
      state_context.pointer,
      pointer
    )
  Util.check_error!(error)
  init(pointer)
end

.with_raw_pointer(pointer) ⇒ ReducedTransaction

Note:

A user of sigma_rb generally does not need to call this function

Takes ownership of an existing ReducedTransaction Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



46
47
48
# File 'lib/sigma/reduced_transaction.rb', line 46

def self.with_raw_pointer(pointer)
  init(pointer)
end

Instance Method Details

#get_unsigned_transactionUnsignedTransaction

Get unsigned transaction

Returns:



52
53
54
55
56
# File 'lib/sigma/reduced_transaction.rb', line 52

def get_unsigned_transaction
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_reduced_tx_unsigned_tx(self.pointer, pointer)
  UnsignedTransaction.with_raw_pointer(pointer)
end