Code Monkey home page Code Monkey logo

bitbank's Introduction

Bitbank

An easy-to-use Ruby interface for the Bitcoind JSON-RPC API. Work in progress :).

Getting Started

First, you need to be running bitcoind. Download and install the official client from http://bitcoin.org/

Next, in order for the client to respond to JSON-RPC commands, you need to enable it in the config file. An example of this and a good explanation of the various options can be found at https://en.bitcoin.it/wiki/Running_Bitcoin

Make sure to set the server, rpcuser, and rpcpassword options.

Connecting

Configure the username and password to match the ones in your bitcoind config. I recommend storing these in a yaml file (see the example config.yml). Once you've done that, you can initialize the client and make requests:

client = Bitbank.new('/path/to/bitbank/config.yml')

Accounts and Account Balances

You can have a number of different Bitcoin accounts and addresses.

account = client.new_account('named-account')

account = client.account('named-account') # or account_by_address
puts "#{account.name} has bitcoin address #{account.address}"

client.accounts.each do |account|
  puts "#{account.name}: #{account.balance}"
end

Or you can get the current balance for all your accounts:

client.balance
# => 10.05

Transactions

Each account also has a list of transactions (both sent and received).

account.transactions.each do |transaction|
  puts "[#{transaction.category}] #{transaction.address} #{transaction.amount}"
end

You can move money between your accounts:

account.move('another-account', 0.5)

And of course you can send payments using the library too:

account.pay('134rUPDEWP8Qp7sShm5bpvmpPtR2mfAeAV', 1.0)

This would send 1 BTC to me. Which would be really awesome, if you'd like to support the continued development of the gem :).

Contributing to Bitbank

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright (c) 2013 Nick Plante. See LICENSE.txt for further details.

bitbank's People

Contributors

zapnap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bitbank's Issues

i18n dependency conflict

What version of rails are you using where you have activesupport >= 3.0.7 and i18n >= 0.6.0 !?!? Bundler tells me that rails ~> 3.0.7 requires i18n 0.5.0

If I use rails 3.1.0.rc4 to get i18n 0.6.0 then bundler complains that bitbank needs that older version of activesupport. I don't see how there could be a way to override rails to use a newer version of i18n ...

Use the money gem, no float!

Please use the money gem! Floats are very bad for currencies... See following example:

irb

1.0 - 0.9
=> 0.09999999999999998

You should require the money gem, define your own currency (bitcoin, 8 decimals after comma (sry for my bad english)) and parse every amount of money with an money object.

What do you think of this?

Use the money gem, no float!

Please use the money gem! Floats are very bad for currencies... See following example:

irb

1.0 - 0.9
=> 0.09999999999999998

You should require the money gem, define your own currency (bitcoin, 8 decimals after comma (sry for my bad english)) and parse every amount of money with an money object.

What do you think of this?

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.