Class: Sigma::UnsignedTransaction
- Inherits:
-
Object
- Object
- Sigma::UnsignedTransaction
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/transaction.rb
Overview
Unsigned (inputs without proofs) transaction
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.with_json(json) ⇒ UnsignedTransaction
Parse from JSON.
-
.with_raw_pointer(pointer) ⇒ UnsignedTransaction
Takes ownership of an existing UnsignedTransaction Pointer.
Instance Method Summary collapse
-
#get_data_inputs ⇒ DataInputs
Get data inputs.
-
#get_output_candidates ⇒ ErgoBoxCandidates
Get output candidates.
-
#get_tx_id ⇒ TxId
Get transaction id.
-
#get_unsigned_inputs ⇒ UnsignedInputs
Get unsigned inputs.
-
#to_json ⇒ String
JSON representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers).
-
#to_json_eip12 ⇒ Object
JSON representation according to EIP-12.
Instance Attribute Details
#pointer ⇒ Object
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
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
A user of sigma_rb generally does not need to call this function
Takes ownership of an existing UnsignedTransaction Pointer.
339 340 341 |
# File 'lib/sigma/transaction.rb', line 339 def self.with_raw_pointer(pointer) init(pointer) end |
Instance Method Details
#get_data_inputs ⇒ DataInputs
Get data inputs
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_candidates ⇒ ErgoBoxCandidates
Get output candidates
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_id ⇒ TxId
Get transaction id
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_inputs ⇒ UnsignedInputs
Get unsigned inputs
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_json ⇒ String
JSON representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)
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_eip12 ⇒ Object
JSON representation according to EIP-12
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 |