Class: Sigma::TxId

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

Overview

Transaction Id

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



422
423
424
# File 'lib/sigma/transaction.rb', line 422

def pointer
  @pointer
end

Class Method Details

.with_raw_pointer(unread_pointer) ⇒ TxId

Note:

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

Takes ownership of an existing TxId Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



439
440
441
# File 'lib/sigma/transaction.rb', line 439

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

.with_string(str) ⇒ TxId

Create from hex-encoded string

Parameters:

  • str (String)

Returns:



427
428
429
430
431
432
433
# File 'lib/sigma/transaction.rb', line 427

def self.with_string(str)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_tx_id_from_str(str, pointer)
  Util.check_error!(error)

  init(pointer)
end

Instance Method Details

#to_sString

Get the TxId as bytes represented with hex-encoded string

Returns:

  • (String)


445
446
447
448
449
450
451
452
453
# File 'lib/sigma/transaction.rb', line 445

def to_s
  s_ptr = FFI::MemoryPointer.new(:pointer, 1)
  error = ergo_lib_tx_id_to_str(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