GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Finance::Bitcoin::API(3) User Contributed Perl Documentation Finance::Bitcoin::API(3)

Finance::Bitcoin::API - wrapper for the Bitcoin JSON-RPC API

 use Finance::Bitcoin::API;
 
 my $uri     = 'http://user:password@127.0.0.1:8332/';
 my $api     = Finance::Bitcoin::API->new( endpoint => $uri );
 my $balance = $api->call('getbalance');
 print $balance;

This module provides a low-level API for accessing a running Bitcoin instance.
"new( %args )"
Constructor. %args is a hash of named arguments. You need to provide the 'endpoint' URL as an argument.
"call( $method, @params )"
Call a method. If successful returns the result; otherwise returns undef.

Caveat: The protocol used to communicate with the Bitcoin daemon is JSON-RPC based. JSON differentiates between numbers and strings: "1" and 1 are considered to be different values. Perl (mostly) does not. Thus the JSON module often needs to guess whether a parameter (i.e. an item in @params) is supposed to be a number or a string. If it guesses incorrectly, this may result in the wrong JSON getting sent to the Bitcoin daemon, and the daemon thus returning an error. To persuade JSON to encode a value as a number, add zero to it; to persuade JSON to encode a value as a string, interpolate it. For example:

   $api->call(
      "sendfrom",
      "$from_adr",  # Str
      "$to_adr",    # Str
      $btc + 0,     # Num
      6,            # literal: perl already knows this is a Num
   );
    
"endpoint"
Get/set the endpoint URL.
"jsonrpc"
Retrieve a reference to the JSON::RPC::Legacy::Client object being used. In particular "$api->jsonrpc->ua" can be useful if you need to alter timeouts or HTTP proxy settings.
"error"
Returns the error message (if any) that resulted from the last "call".

Please report any bugs to <http://rt.cpan.org/>.

Finance::Bitcoin.

<http://www.bitcoin.org/>.

Toby Inkster <tobyink@cpan.org>.

Copyright 2010, 2011, 2013, 2014 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2014-03-10 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.