class Bitcoin::Account

Overview

An example implementation of a Bitcoin account using an Secp256k1 keypair and a Bitcoin network version identifier; only for educational purposes and should not be used in production.

Defined in:

bitcoin.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(key : Secp256k1::Key = Key.new, version : Secp256k1::Num = Num.new("0x00")) #

Creates a Bitcoin account from a given Secp256k1::Key keypair and for the specified network version, e.g., 00 for Bitcoin main network. It creates a random account if no parameters are supplied.

Parameters:

priv = Secp256k1::Num.new "18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725"
key = Secp256k1::Key.new priv
account = Bitcoin::Account.new key
# => #<Bitcoin::Account:0x7f2611dcab40
#         @key=#<Secp256k1::Key:0x7f261ae90ee0
#               @private_key=#<Secp256k1::Num:0x7f261ae93300
#                   @hex="18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725",
#                   @dec=11253563012059685825953619222107823549092147699031672238385790369351542642469,
#                   @bin=Bytes[24, 225, 74, 123, 106, 48, 127, 66, 106, 148, 248, 17, 71, 1, 231, 200, 231, 116, 231, 249, 164, 126, 44, 32, 53, 219, 41, 162, 6, 50, 23, 37]>,
#               @public_key=#<Secp256k1::Point:0x7f261ae90d20
#                   @x=#<Secp256k1::Num:0x7f2611dcabc0
#                       @hex="50863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352",
#                       @dec=36422191471907241029883925342251831624200921388586025344128047678873736520530,
#                       @bin=Bytes[80, 134, 58, 214, 74, 135, 174, 138, 47, 232, 60, 26, 241, 168, 64, 60, 181, 63, 83, 228, 134, 216, 81, 29, 173, 138, 4, 136, 126, 91, 35, 82]>,
#                   @y=#<Secp256k1::Num:0x7f2611dcab80
#                       @hex="2cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6",
#                       @dec=20277110887056303803699431755396003735040374760118964734768299847012543114150,
#                       @bin=Bytes[44, 212, 112, 36, 52, 83, 162, 153, 250, 158, 119, 35, 119, 22, 16, 58, 188, 17, 161, 223, 56, 133, 94, 214, 242, 238, 24, 126, 156, 88, 43, 166]>>>,
#         @version=#<Secp256k1::Num:0x7f2611dcab00
#               @hex="00",
#               @dec=0,
#               @bin=Bytes[0]>,
#         @address="16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM",
#         @address_compressed="1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs",
#         @wif="5J1F7GHadZG3sCCKHCwg8Jvys9xUbFsjLnGec4H125Ny1V9nR6V",
#         @wif_compressed="Kx45GeUBSMPReYQwgXiKhG9FzNXrnCeutJp4yjTd5kKxCitadm3C">

[View source]

Instance Method Detail

def address : String #

The public, uncompressed Bitcoin account address.


[View source]
def address_compressed : String #

The public, compressed Bitcoin account address.


[View source]
def key : Key #

The Secp256k1 keypair for the account.


[View source]
def version : Num #

The network version indicator.


[View source]
def wif : String #

The private, uncompressed wallet-import format.


[View source]
def wif_compressed : String #

The private, compressed wallet-import format.


[View source]