Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coinselect

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coinselect

A fee optimizing bitcoin input selection module

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-6.47%
Maintainers
1
Weekly downloads
 
Created
Source

coinselect

TRAVIS NPM

js-standard-style

A fee-optimizing, transaction input selection module for bitcoinjs-lib.

The code is stable.

The module's interface/existence is not.

Please let me know if you are using this package.

Example

var coinSelect = require('coinselect')

var feeRate = 55 // satoshis per byte
var unspents = [
	...,
	{
		...,
		value: 10000
	}
]
var outputs = [
	...,
	{
		address: '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm',
		value: 5000
	}
]

var result = coinselect(unspents, outputs, feeRate)

// the accumulated fee is always returned
console.log(result.fee)

// .inputs may be null if not enough funds exist
if (!result.inputs) return

// success!
var txb = new bitcoin.TransactionBuilder()

// is a change output non-dust?
if (result.remainder > 5460) {
	txb.addOutput(changeAddress, result.remainder)
}

Feedback welcome on the API, I'm not sure if I like it.

License MIT

Keywords

FAQs

Package last updated on 31 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc