Coder Social home page Coder Social logo

mikalv / bitcoin-client Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sinisterchipmunk/bitcoin-client

0.0 3.0 0.0 71 KB

Provides a Ruby library to the complete Bitcoin JSON-RPC API. Implements all methods listed at https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list .

Ruby 100.00%

bitcoin-client's Introduction

bitcoin-client <img src=“https://travis-ci.org/sinisterchipmunk/bitcoin-client.png?branch=master” alt=“Build Status” /> <img src=“https://codeclimate.com/github/sinisterchipmunk/bitcoin-client.png” /> <img src=“https://coveralls.io/repos/sinisterchipmunk/bitcoin-client/badge.png” alt=“Coverage Status” />

Provides a Ruby library to the complete Bitcoin JSON-RPC API. Implements all methods listed at en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list. Also supports customizing the host and port number to connect to.

Installation

On Ruby 1.9, you can just install the gem and start using it. On 1.8, the ‘json’ gem is also required, so you’ll need to install that first:

gem install json

Or, if you’re using Bundler (and you should be), just add it to the Gemfile:

gem 'json', '~> 1.5.3'

Usage

As with most Ruby gems, you first need to require the library into your project:

require 'bitcon_client'

After doing this, the simplest possible usage looks like this:

BitcoinClient('username', 'password').balance
# => 0.001

Or, if you prefer a somewhat more explicit representation, the following code performs the exact same task:

client = BitcoinClient::Client.new('username', 'password')
client.balance
# => 0.001

The third and final way to use the library is by taking advantage of a simple DSL:

include BitcoinClient

# set up credentials
username 'username'
password 'password'

balance
# => 0.001

accounts
# => {"account" => 0.001}

The RPC method names available to you are exactly the same as those listed on the Bitcoin wiki (again, that’s en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list). Some aliases have been added to make them more “ruby-ish,” but none of the original names have been changed.

Host, Port and SSL

Here are several examples of how you can change the host information:

BitcoinClient('username', 'password', :host => 'example.com', :port => 38332, :ssl => true)

client = BitcoinClient::Client.new('username', 'password', :host => 'example.com')
client.port = 38332
client.ssl = true
client.ssl?
# => true

include BitcoinClient
host 'example.com'
port 38332
ssl?
# => false
ssl true
ssl?
# => true

You should see the BitcoinClient::Client class documentation if you’d like to see the other options and methods that are made available.

Donations

If you found this library useful and feel inclined to compensate me for my trouble, I’m certainly not going to turn you down!

Bitcoin donations can be sent to:

1HawYer58J9Vy3iju1w7jsRVci5tzaxkwn

Thanks!

bitcoin-client's People

Contributors

andruby avatar beho avatar cgcardona avatar flaneur2020 avatar juwalter avatar kyledrake avatar mikalv avatar ramontayag avatar rampa069 avatar sinisterchipmunk avatar smazhara avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.