bitcoin-payment-microservice v0.2.7
Micro Bitcoin Payment Service
A micro service for adding bitcoin payment to your node application. using node 8.0
Prerequisites
To install the module you need to have node install in your loacl machine and also npm / yarn.
Testing
To run a unit test run the following command
npm run testUsage
To use with the micro service you need to install some module first with.
npm install --save bitcoin-payment-mircoserviceOr you use yarn to install the package
yarn add bitcoin-payment-mircoservicethen in, your javascript file.
const bitcoinPayment = require('bitcoin-payment-mircoservice')To get the current bitcoin balance of an address
const balance = bitcoinPayment.getBalance(address) // return address balance
console.log('bitcoin Balance', balance)returns
bitcoin Balance 0.009797To Generate a bitcoin address
const address = bitcoinPayment.createAddress() // return a bitcoin address with private key
console.log(address)returns
{
address: '1K3QovFjbXG9HMYSfTE8WMc7EHhhpJSGwT',
privateKey: 'achgjxsdvhjahkjlxkdcbazagshkjlskncvgshjasluyihkjaknjxs'
}
** NOTE: Please always secure your private keyTo send Bitcoin to an address
sendBTC (paperWallet, toAddress, amount, network) => transactionID
// paperWallet - Generated address with private key to validate the transaction
// amount - amount to be sent in satoshi
// toAddress - Bitcoin address to receive the amount
// network - which could either 'testnet' or 'livenet/mainnet'To listen to an address on a network for transaction
bitcoinPayment.litenToLiveTransaction(address) => txWill trigger the event in real time if a payment is done to that address:
Transaction detected! { address: '138WJKb1mXbkRGNpyMVEZ9EsoXjMEvJfT4',
amount: 381000 }8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago