BTC::Address is a base class for P2PKH, P2SH addresses and WIF private key serialization format. It is defined in address.rb.
Use BTC::Address to decode addresses of the unknown type (or when it does not matter). Use subclasses to encode addresses of a specific type.
If argument
is a String, parses it and returns an instance of one of the concrete subclasses of BTC::Address.
If argument
is a subclass of BTC::Address returns argument
.
>> Address.parse("1CBtcGivXmHQ8ZqdPgeMfcpQNJrqTrSAcG")
=> #<BTC::PublicKeyAddress:1CBtcGiv...>
>> Address.parse("3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8")
=> #<BTC::ScriptHashAddress:3NukJ6fY...>
>> Address.parse("5KQntKuhYWSRXNqp2yhdXzjekYAR7US3MT1715Mbv5CyUKV6hVe")
=> #<BTC::WIF:5KQntKuh... privkey:d20b62cd... (uncompressed pubkey)>
Returns an underlying binary string stored within an address. For WIF format it is a 32-byte private key. For P2PKH or P2PSH addresses it is a 20-byte hash.
Returns string representation of the address in Base58Check encoding.
Returns a BTC::Network instance based on version prefix of the address (mainnet or testnet).
Returns an integer value of the one-byte prefix of the address.
Returns a corresponding public address. Typically returns self
, but for WIF returns
an address based on the public key corresponding to the WIF-encoded private key.
Returns true
if this address is a subclass of PublicKeyAddress. Otherwise returns false
.
Returns true
if this address is a subclass of ScriptHashAddress. Otherwise returns false
.
Returns true
if underlying data and versions of both addresses match.