Skip to content

Latest commit

 

History

History
72 lines (37 loc) · 1.95 KB

wif.md

File metadata and controls

72 lines (37 loc) · 1.95 KB

Index

BTC::WIF

A subclass of BTC::Address that represents a serialized private key in a Wallet Import Format (WIF), also known as "sipa format".

Initializers

new(string: String)

Returns a new WIF by parsing a Base58Check-encoded string (must be a valid WIF string).

new(private_key: String, network: BTC::Network, public_key_compressed: false|true)

Returns a new WIF with the 32-byte binary string private_key.

If network is not specified, BTC::Network.default is used.

If public_key_compressed is not specified, false is used.

new(key: BTC::Key, network: BTC::Network, public_key_compressed: false|true)

Returns a new WIF with key.private_key.

Raises ArgumentError if key does not have a private_key component.

If network is not specified, key.network is used (instance of BTC::Network).

If public_key_compressed is not specified, key.public_key_compressed is used.

Instance Methods

key

Returns a BTC::Key instance represented by the WIF. The returned object inherits network and public_key_compressed attributes.

private_key

Returns raw binary 32-byte private key stored in WIF.

to_s

Returns string representation of the WIF in Base58Check encoding.

public_address

Returns BTC::PublicKeyAddress instance corresponding to this key's public key.

public_key_compressed

Returns true or false depending on whether the corresponding public key should be compressed (33 bytes) or not (65 bytes).

network

Returns a BTC::Network instance based on the version prefix of the address (mainnet or testnet).

version

Returns an integer value of the one-byte prefix of the WIF encoding. 128 for mainnet, 239 for testnet.

p2pkh?

Returns false.

p2sh?

Returns false.