spend
Create simple Bitcoin / Testnet transactions for integration testing with the actual network.
Last updated 5 years ago by jprichardson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install spend 
SYNC missed versions from official npm registry.

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 encoded string.
  • toAddress: Recipient address. Should be base58 encoded string.
  • amount: Amount in satoshis. Should be an integer. Either number or string.
  • changeAddress: Optional change address. If not specified, address calculated from fromWIF will be used.
  • callback: Callback with result. Signature: (err, txId, rawTx). Where txId is a string representing the transaction ID and rawTx is the transaction serialized as a string.

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 = require('cb-insight') // npm i --save cb-insight
var spend = require('spend')

// set common blockchain provider
spend.blockchain = new Blockchain('https://test-insight.bitpay.com')

var fromWIF = '...'
var toAddress = '...'
var amountSatoshis = 500000

spend(fromWIF, toAddress, amountSatoshis, function (err, txId) {
  // use txId to track transaction
  console.log(txId)
})

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:

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

Current Tags

  • 0.0.1                                ...           latest (5 years ago)

1 Versions

  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |