Spend
A JavaScript component to create simple Bitcoin / Testnet transactions for integration testing with the actual network. Can be used in Node.js or the browser (via Browserify).
Install
npm i --save spend
Usage
spend(fromWIF, toAddress, amount, [changeAddress], callback)
fromWIF
: Private key with matching address that contains funds. Should be base58 check encodedstring
.toAddress
: Recipient address. Should be base58 encodedstring
.amount
: Amount in satoshis. Should be an integer. Eithernumber
orstring
.changeAddress
: Optional change address. If not specified, address calculated fromfromWIF
will be used.callback
: Callback with result. Signature:(err, txId, rawTx)
. WheretxId
is astring
representing the transaction ID andrawTx
is the transaction serialized as astring
.
Common Blockchain
Common Blockchain is a unified way to access a blockchain via an API provider. i.e. it provides the same methods and normalizes results no matter who the API provider is.
You'll need to bring your own Common Blockchain provider. Here's a list: https://github.com/common-blockchain/common-blockchain/issues/21
Example:
var Blockchain = // npm i --save cb-insightvar spend = // set common blockchain providerspendblockchain = 'https://test-insight.bitpay.com' var fromWIF = '...'var toAddress = '...'var amountSatoshis = 500000
Limitations
- fixed fee
- bitcoin/testnet only at the moment
- simplified outputs (may change to allow additional like
OP_RETURN
) - merges all UTXOs
Bitcoin Testnet Faucets
You'll want some Bitcoin Testnet coins to test your applications. You can get them from any of the following faucets:
- http://tpfaucet.appspot.com/
- http://faucet.luis.im/
- http://testnet.bitcoin.peercoinfaucet.com/
- https://testnet.coinfaucet.eu/en/
- http://faucet.haskoin.com/
Test Spending
Wanna test spending these coins? Checkout the Coinbolt Cat Shop to test your bitcoin applications by buying fake cats that share economic wisdom.
License
MIT