Skip to content

Latest commit

 

History

History
60 lines (33 loc) · 1.86 KB

extensions.md

File metadata and controls

60 lines (33 loc) · 1.86 KB

Index

Core Extensions

Core Extensions are convenience methods available on standard classes like String. We do not extend core classes by default to avoid conflicts with other libraries and your own extensions. To enable convenience methods, include btcruby/extensions.rb in your application.

Extensions are automatically available in BTCRuby interactive console bin/console and in unit tests.

String Extensions

to_wif(network: BTC::Network, public_key_compressed: false|true)

Converts a binary string representing a 32-byte private key to WIF format.

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

If public_key_compressed is not specified, false is used.

from_wif

Converts WIF-encoded string to a raw 32-byte private key. Raises FormatError if the receiver is not a valid WIF-encoded string.

to_hex

Converts a binary string to a hex-encoded string.

from_hex

Converts a hex-encoded string to a binary string. Raises FormatError if the receiver is not a valid hex-encoded string.

sha1

Returns a binary string compressed using SHA-1 algorithm.

sha256

Returns a binary string compressed using SHA-256 algorithm.

sha512

Returns a binary string compressed using SHA-512 algorithm.

ripemd160

Returns a binary string compressed using RIPEMD-160 algorithm.

hash256

Returns a binary string compressed using two passes of SHA-256 algorithm. Known in Bitcoin as Hash256.

hash160

Returns a binary string compressed using composition ripemd160(sha256(string)). Known in Bitcoin as Hash160.