Set up your own bitcoin payment system the easy way(with 4 APIs).
npm install cryptoo
const Cryptoo = require('cryptoo');
// Create a cryptoo instance
// Start syncing blockchain data
const cryptoo = new Cryptoo({
secret: 'sample-secret-e34dc9dff1b8b04c2b678ff7bb1dd02181bfe31b045f77',
});
// Get recovery phrase to backup your HD wallet
cryptoo.getRecoveryPhrase();
// Generate address to receive coins(shoud be recorded for looking up later)
cryptoo.createAddress();
// Fires when an unconfirmed transaction is received to your address
cryptoo.on('unconfirmedTx', ({ address, txHash, value }) => {
console.log(`saw tx ${value} for ${address}`);
});
// Fires when a transaction to your address has one confirmation
cryptoo.on('confirmedTx', ({ address, txHash, value }) => {
console.log(`received ${value} for ${address}`);
});
new Cryptoo({
// default 'main', can also be 'testnet'
network: 'main',
// default '~/.bcoin', where to store blockchain and wallet data
chainDataFolder: '~/.bcoin',
// default: null, secret is used to protect your wallet api, so that if you open port 8332 accedently, other people wll not be able to access you wallet
secret: 'v8ZgxMBicQKsPd1jmUQY2WBfrmK4tVMfAiSCh6xZXVMcNoDoyjLDRKe',
// default: false, wether to show bcoin log in console, useful for debuging
logBcoinLogInConsole: false,
});
- Cryptoo landing page with bitcoin donation; [source code]
- TO BE ADDED
All the major functionlites of Cryptoo is provided by bcoin, Cryptoo is a simple wrapper over bcoin, exposing necessary apis to provide an easier api interface for user to build a payment system. It's about 160 lines of code.
Bcoin is able to start and mantain bitcoin SPV node(light weight node) and also HD wallet(able to derive unlimited addresses from a seed key(recovery phrase))
When Cryptoo
instance is created, it will start an SPV node and prepare an HD wallet for you.
Depend on your network enviroment, it might take one to severial hours to sync the blockchain data, the blockchain data and wallet info will be stored in chainDataFolder
you configure.
- Close 8332 port: for now cryptoo is a wrapper on bcoin, and bcoin will start an http server listening on this port for accessing wallet data, it's recommand to disable 8332 port for external access.
- Define a complex api-key: if you are not able to close 8332 port, you should define a complex api-key
As the wallet provided is an HD wallet, once you get the recovery phrase by invoking the getRecoveryPhrase()
API. You can access you wallet by importing it to any wallet support bip44
- cryptoo-eth
- faucet testnet bitcoin: http://bitcoinfaucet.uo1.net/send.php