NAME
Business::Bitcoin - Easy and secure way to accept Bitcoin payments online
VERSION
$Revision: 1.028 $
$Date: Sun Jan 22 10:34:32 PST 2017 $
SYNOPSIS
An easy and secure way to accept Bitcoin payments online using an HD wallet, generating new receiving addresses on demand and keeping the wallet private key offline.
use Business::Bitcoin;
my $bizbtc = new Business::Bitcoin (DB => '/tmp/bizbtc.db',
XPUB => 'xpub...',
Create => 1);
my $req = $bizbtc->request(Amount => 4200);
print 'Please pay ' . $req->amount . ' Satoshi ' .
'to Bitcoin address ' . $req->address . ".\n" .
'Once the payment has ' . $req->confirmations , ' confirmations, ' .
"press <enter> to continue.\n";
readline(*STDIN);
print ($req->verify ? "Verified\n" : "Verification failed\n");
print "Enter a request address to verify a payment.\n";
my $address = <STDIN>; chomp $address;
my $req2 = $bizbtc->findreq(Address => $address);
print ($req2->verify ? "Verified\n" : "Verification failed\n");
HOW TO USE
To start receiving Bitcoin payments online, create an HD wallet using any HD wallet app (e.g. Electrum, Bitcoin Armory), get the "Master Public Key" for the wallet (a string beginning with "xpub") and plug it into the constructor's XPUB argument).
Now you can receive online payments as outlined above, while keeping your private key secure offline. You should still take all precautions to ensure that your XPUB key on the server is also safe, as its compromise can weaken your security, though it can't in itself lead to the loss of any Bitcoin.
METHODS
new
Create a new Business::Bitcoin object and open (or create) the requests database. The following named arguments are required:
DB - The filename of the requests database
XPUB - The master public key for the wallet receiving payments
The following optional named arguments can be provided:
Create - Create the requests table if it doesn't exist. If the table doesn't exist and Create is not true, the constructor will return undef. Unset by default.
Clobber - Wipe out any existing database file first. Unset by default.
StartIndex - Start generating receiving keys from the specified index rather than from 0. Useful if you've already used some receiving addresses before starting to receive payments using this module. Only relevant when Create is true and a new requests table is being created. Ignored when an existing requests table is being used; in that case the index is generated by the database. By default, receiving addresses will be generated starting from the first one, at index 0.
request
Create a new payment request and generate a new receiving address. Returns a Business::Bitcoin::Request object if successful, or undef on error. The following named argument is required:
Amount - The amount of the payment requested, in Satoshi.
The following optional named arguments can be provided:
Confirmations - The number of confirmations needed to verify payment of this request. The default is 5.
Reference - Optional reference ID to be associated with the request, to facilitate integration with existing ordering systems. If a reference ID is provided it should be unique for each request.
findreq
Find a previously created payment request, by either Address or Reference. Returns a Business::Bitcoin::Request object if successful, or undef on error. Exactly one of the following named arguments is required:
Address - The receiving address associated with the payment request
Reference - The reference ID associated with the payment request
The following optional named argument can be provided:
Confirmations - The number of confirmations needed to verify payment of this request. The default is 5.
ACCESSORS
Accessors can be called with no arguments to query the value of an object property, or with a single argument, to set the property to a specific value (unless the property is read only).
db
The filename of the requests DB file.
xpub
The master public key from which all receiving keys are generated.
version
The version number of this module. Read only.
PREREQUISITES
DBD::SQLite
Used to keep track of payment requests.
LWP and an Internet connection
Required to verify payments. Currently this is done via the blockchain.info API.
AUTHOR
Ashish Gulhati, <biz-btc at hash dot neomailbox.ch>
BUGS
Please report any bugs or feature requests to bug-business-bitcoin at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Business-Bitcoin. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Business::Bitcoin
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
Copyright (c) 2016-2017 Ashish Gulhati. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.