This package can be used to generate Bech32 Bitcoin wallets and also transact on the Bitcoin testnet.
- generateP2PKH()
- generateBECH32()
- signAndSendTransaction()
- generateTestAccounts()
Install this package using,
npm install --save btc-utils
Import this package using,
const bitcoin = require('btc-utils');
const p2pkhWallet = bitcoin.generateP2PKH();
privateKey
- Private Key of the wallet.publicKey
- Public Key of the wallet.address
- Address of the wallet.
const bech32Wallet = bitcoin.generateBECH32();
privateKey
- Private Key of the wallet.publicKey
- Public Key of the wallet.privateKeyWIF
- Private key in WIF (Wallet Import Format).address
- Address of the wallet.
const testWallet = bitcoin.generateTestAccounts();
private
- Private Key of the wallet.public
- Public Key of the wallet.address
- Address of the wallet.wif
- Private key in WIF (Wallet Import Format).
const btcTx = bitcoin.signAndSendTransaction({ fromAddress, toAddress, value, privateKeyWIF });
fromAddress
- Address of the wallet to send the transaction from (sender).toAddress
- Address of the wallet to send the transaction to (recepient).value
- Amount of Bitcoins (in satoshis).privateKeyWIF
- Private key of the sender in WIF (Wallet Import Format).
response: {transactionHash} - Transaction Hash of that particular transaction.
error: 'Insufficient funds.'
error: 'Incorrect private Key.'