Class: AdequateCryptoAddress::Btc
- Inherits:
-
Object
- Object
- AdequateCryptoAddress::Btc
- Defined in:
- lib/adequate_crypto_address/btc.rb
Constant Summary collapse
- BASE58_TYPES =
{ '00' => :hash160, '05' => :p2sh, '6f' => :hash160test, 'c4' => :p2shtest }.freeze
- BASE58_NETWORKS =
{ '00' => :mainnet, '05' => :mainnet, '6f' => :testnet, 'c4' => :testnet }.freeze
- SEGWIT_NETWORKS =
{ 'bc' => :mainnet, 'tb' => :testnet }.freeze
- MAX_LENGTH =
100
Instance Attribute Summary collapse
-
#address ⇒ Object
(also: #raw_address)
readonly
Returns the value of attribute address.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#address_type ⇒ Object
Public contract: the detected type Symbol, or nil when invalid.
-
#initialize(address) ⇒ Btc
constructor
A new instance of Btc.
- #valid?(validated_type = nil) ⇒ Boolean
Constructor Details
#initialize(address) ⇒ Btc
Returns a new instance of Btc.
18 19 20 21 |
# File 'lib/adequate_crypto_address/btc.rb', line 18 def initialize(address) @address = address @type = detect_type end |
Instance Attribute Details
#address ⇒ Object (readonly) Also known as: raw_address
Returns the value of attribute address.
15 16 17 |
# File 'lib/adequate_crypto_address/btc.rb', line 15 def address @address end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
15 16 17 |
# File 'lib/adequate_crypto_address/btc.rb', line 15 def network @network end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'lib/adequate_crypto_address/btc.rb', line 15 def type @type end |
Instance Method Details
#address_type ⇒ Object
Public contract: the detected type Symbol, or nil when invalid. The SegWit type is network-agnostic; use #network to enforce mainnet/testnet.
31 32 33 |
# File 'lib/adequate_crypto_address/btc.rb', line 31 def address_type type end |
#valid?(validated_type = nil) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/adequate_crypto_address/btc.rb', line 23 def valid?(validated_type = nil) return !type.nil? unless validated_type type == validated_type.to_sym end |