Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

silkroad

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

silkroad

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Silkroad

A fast, thread-safe, simple, lightweight, batchable interface to the bitcoind JSON-RPC api. Uses HTTPClient for high performance.

Installation

Add this line to your application's Gemfile:

gem 'silkroad'

And then execute:

$ bundle

Or install it yourself as:

$ gem install silkroad

Usage

Initialize the client:

silkroad = Silkroad::Client.new

You can set a custom uri:

silkroad = Silkroad::Client.new 'https://rpcuser:rpcpass@yourbitcoinddaemon.com:31337'

Now you can make RPC API calls (see the API calls list). Pass params as per the spec, and the result will be returned as a primitive type (string, number, boolean, and nil) or structured type (hash, array), depending on the call:

silkroad.rpc 'getbalance', 'derp@example.com' # => 31337

Errors throw the Silkroad::Client::Error exception. Catch it if you want to do something custom:

begin
  silkroad.rpc 'failcmd', 'fail'
rescue Silkroad::Client::Error => e
  puts "Error: #{e.inspect}"
end

Batching

If you use batching, it will throw all your requests into a JSON array, send them at once, and return all of them when they are done, per the JSON-RPC spec. Batch is much lower level, and does not raise exceptions on errors. You will need to look for the response[index]['error'] in the return and handle it.

response = @silkroad.batch do
  rpc 'getbalance', 'tyler@example.com'
  rpc 'notworking', 'derp'
end

# response is:
[
  {result: 31337, error: nil, id: nil},
  {result: nil, error: {code: -32601, message: 'Method not found'}, id: nil}
]

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Winners Don't Use Drugs - William S. Sessions, Director, FBI

FAQs

Package last updated on 22 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc