Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby Bitcoin Library
Ruby Perl
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
test
History.txt
Manifest.txt
README.rdoc
TODO.txt
btc.gemspec
project.gemspec

README.rdoc

BTC

github

www.github.com/carlosjhr64/btc

rubygems

rubygems.org/gems/btc

DESCRIPTION:

BTC is a Ruby Library to create Bitcoin private/public key pairs.

It subclasses OpenSSL::PKey::EC, and adds attributes related to Bitcoin.

FEATURES:

  • Easy Bitcoin address and private key.

  • Easy Bitcoin address from the hexadecimal private key.

SYNOPSIS:

coin = BTC::Btc.coin
address = coin.address
hexadecimal_private_key = coin.prvkey
# From a given private key...
same_coin = BTC::Btc.coin(hexadecimal_private_key)

BUT WAIT THERE'S MORE!:

Besides the methods above and those available to OpenSSL::PKey::EC, you also have:

coin.pubkey # hexadecimal public_key
coin.hash160
coin.checksum
coin.private_key!(hexadecimal_private_key) # updates entirely

The class method BTC::Btc.coin is just a wrap of:

# Mind that this is a OpenSSL::PKey::EC subclass
coin = BTC::Btc.new('secp256k1')
coin.generate_key

And BTC::Btc.coin(hexprvkey) is just a wrap of:

coin = BTC::Btc.new('secp256k1')
coin.private_key!(prvkey)

Where private_key! is:

self.private_key = prvkey.to_i(16)
self.public_key  = self.group.generator.mul(self.private_key)

BTC::Btc overloads #private_key= and #public_key= to update the additional Bitcoin attributes.

INSTALL:

$ sudo gem install btc

REQUIREMENTS:

BTC only uses the Standard Libraries. For testing, I used:

Credits

lian / bitcoin-ruby

Good Ruby source for Bitcoin.

How to create Bitcoin Address

The Bitcoin Wiki page on…

LICENCE:

(The MIT License)

Copyright © 2014 CarlosJHR64

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.