Class: Sigma::UnsignedTransaction

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

Overview

Unsigned (inputs without proofs) transaction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



323
324
325
# File 'lib/sigma/transaction.rb', line 323

def pointer
  @pointer
end

Class Method Details

.with_json(json) ⇒ UnsignedTransaction

Parse from JSON. Supports Ergo Node/Explorer API and box values and token amount encoded as strings

Parameters:

  • json (String)

Returns:



328
329
330
331
332
333
# File 'lib/sigma/transaction.rb', line 328

def self.with_json(json)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_unsigned_tx_from_json(json, pointer)
  Util.check_error!(error)
  init(pointer)
end

.with_raw_pointer(pointer) ⇒ UnsignedTransaction

Note:

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

Takes ownership of an existing UnsignedTransaction Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



339
340
341
# File 'lib/sigma/transaction.rb', line 339

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

Instance Method Details

#get_data_inputsDataInputs

Get data inputs

Returns:



361
362
363
364
365
# File 'lib/sigma/transaction.rb', line 361

def get_data_inputs
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_unsigned_tx_data_inputs(self.pointer, pointer)
  Sigma::DataInputs.with_raw_pointer(pointer)
end

#get_output_candidatesErgoBoxCandidates

Get output candidates

Returns:



369
370
371
372
373
# File 'lib/sigma/transaction.rb', line 369

def get_output_candidates
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_unsigned_tx_output_candidates(self.pointer, pointer)
  Sigma::ErgoBoxCandidates.with_raw_pointer(pointer)
end

#get_tx_idTxId

Get transaction id

Returns:



345
346
347
348
349
# File 'lib/sigma/transaction.rb', line 345

def get_tx_id
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_unsigned_tx_id(self.pointer, pointer)
  Sigma::TxId.with_raw_pointer(pointer)
end

#get_unsigned_inputsUnsignedInputs

Get unsigned inputs

Returns:



353
354
355
356
357
# File 'lib/sigma/transaction.rb', line 353

def get_unsigned_inputs
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_unsigned_tx_inputs(self.pointer, pointer)
  Sigma::UnsignedInputs.with_raw_pointer(pointer)
end

#to_jsonString

JSON representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)

Returns:

  • (String)


377
378
379
380
381
382
383
384
385
# File 'lib/sigma/transaction.rb', line 377

def to_json
  s_ptr = FFI::MemoryPointer.new(:pointer, 1)
  error = ergo_lib_unsigned_tx_to_json(self.pointer, s_ptr)
  Util.check_error!(error)
  s_ptr = s_ptr.read_pointer()
  str = s_ptr.read_string().force_encoding('UTF-8')
  Util.ergo_lib_delete_string(s_ptr)
  str
end

#to_json_eip12Object

JSON representation according to EIP-12

See Also:



389
390
391
392
393
394
395
396
397
# File 'lib/sigma/transaction.rb', line 389

def to_json_eip12
  s_ptr = FFI::MemoryPointer.new(:pointer, 1)
  error = ergo_lib_unsigned_tx_to_json_eip12(self.pointer, s_ptr)
  Util.check_error!(error)
  s_ptr = s_ptr.read_pointer()
  str = s_ptr.read_string().force_encoding('UTF-8')
  Util.ergo_lib_delete_string(s_ptr)
  str
end