Class: Sigma::TxId
- Inherits:
-
Object
- Object
- Sigma::TxId
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/transaction.rb
Overview
Transaction Id
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.with_raw_pointer(unread_pointer) ⇒ TxId
Takes ownership of an existing TxId Pointer.
-
.with_string(str) ⇒ TxId
Create from hex-encoded string.
Instance Method Summary collapse
-
#to_s ⇒ String
Get the TxId as bytes represented with hex-encoded string.
Instance Attribute Details
#pointer ⇒ Object
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.
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
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_s ⇒ String
Get the TxId as bytes represented with hex-encoded 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 |