Giter Club home page Giter Club logo

bitcoin_node's Introduction

BitcoinNode

Study of Bitcoin protocol by implementing a simple node in the p2p bitcoin network.

Using as much as Ruby stdlib as possible. Main foreign dependency is Celluloid::IO

Installation

Add to your Gemfile gem 'bitcoin_node' or locally run

$ gem install bitcoin_node

Test

$ bundle exec rspec

Usage

Create messages

require 'bitcoin_node'

ping = BitcoinNode::Protocol::Messages.ping
# => #<BitcoinNode::Protocol::Message:0x007feb24e1fa20 @payload=#<Ping {:nonce=>#<struct Integer64Field 12031756400052209357>}>, @command="ping">

ping.raw
# => "\xF9\xBE\xB4\xD9ping\x00\x00\x00\x00\x00\x00\x00\x00\b\x00\x00\x00\xAB\x0F\x0FZ\x95\xDC{\xA1\xB1i\x11]"

version = BN::Protocol::Messages.version

Single client

require 'bitcoin_node'

host = '144.76.217.165'

client = BN::P2P::Client.connect(host)

client.send(BN::Protocol::Messages.version)
client.send(BN::Protocol::Messages.ping)
client.send(BN::Protocol::Messages.getaddr)

bitcoin_node's People

Contributors

simcap avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

bitcoin_node's Issues

Integration tests fail with 'Errno::EADDRINUSE'

All tests in spec/integration/version_handshake_spec.rb bind BN::P2p::Server to port 3333. It's not ensured that the socket opened by a previous test is already closed when the next test starts.

This leads to an error:
Errno::EADDRINUSE: Address already in use - bind(2) for "localhost" port 3333

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.