Class: Sigma::Address
- Inherits:
-
Object
- Object
- Sigma::Address
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/address.rb
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
- .with_base58_address(address_str) ⇒ Object
- .with_mainnet_address(address_str) ⇒ Object
- .with_raw_pointer(unread_pointer) ⇒ Object
- .with_testnet_address(address_str) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
16 17 18 |
# File 'lib/sigma/address.rb', line 16 def pointer @pointer end |
Class Method Details
.with_base58_address(address_str) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/sigma/address.rb', line 38 def self.with_base58_address(address_str) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_address_from_base58(address_str, pointer) Util.check_error!(error) init(pointer) end |
.with_mainnet_address(address_str) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/sigma/address.rb', line 30 def self.with_mainnet_address(address_str) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_address_from_mainnet(address_str, pointer) Util.check_error!(error) init(pointer) end |
.with_raw_pointer(unread_pointer) ⇒ Object
18 19 20 |
# File 'lib/sigma/address.rb', line 18 def self.with_raw_pointer(unread_pointer) init(unread_pointer) end |
.with_testnet_address(address_str) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/sigma/address.rb', line 22 def self.with_testnet_address(address_str) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_address_from_testnet(address_str, pointer) Util.check_error!(error) init(pointer) end |
Instance Method Details
#to_base58(network_prefix) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/sigma/address.rb', line 46 def to_base58(network_prefix) s_ptr = FFI::MemoryPointer.new(:pointer, 1) pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_address_to_base58(self.pointer, network_prefix, s_ptr) s_ptr = s_ptr.read_pointer() str = s_ptr.read_string().force_encoding('UTF-8') Util.ergo_lib_delete_string(s_ptr) str end |
#type_prefix ⇒ Object
56 57 58 |
# File 'lib/sigma/address.rb', line 56 def type_prefix ergo_lib_address_type_prefix(self.pointer) end |