# coinselection-ts

> Coin selection library in typescript

Latest version **2.0.1** (published 2021-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install coinselection-ts
pnpm add coinselection-ts
yarn add coinselection-ts
bun add coinselection-ts
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2021-12-22 |
| First published | 2021-12-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Bruno Garcia |
| Maintainers | brunoerg |

## Links

- npm: https://www.npmjs.com/package/coinselection-ts
- Repository: https://github.com/brunoerg/coinselection-ts
- Homepage: https://github.com/brunoerg/coinselection-ts#readme
- Issues: https://github.com/brunoerg/coinselection-ts/issues
- npm.io page: https://npm.io/package/coinselection-ts

## Dependencies (1)

- [typescript](https://npm.io/package/typescript.md) ^4.2.3

## Recent versions

- 2.0.1 (latest) — 2021-12-22
- 2.0.0 — 2021-12-22
- 1.0.3 — 2021-12-22
- 1.0.1 — 2021-12-05
- 1.0.0 — 2021-12-03

## README

# coinselection-ts
Coin selection library in Typescript

This library adopts the same strategy of Bitcoin Core. It implements Branch and Bound, Knapsack and SRD algorithms and uses a waste metric to decide what solution will be used. Obs.: Some parts of this library is based on coinselect (https://github.com/bitcoinjs/coinselect).

## Install

```
npm i --save coinselection-ts
```

## How to use

```javascript
import { coinselection } from "coinselection-ts"

const fee_rate = 1; //satoshis per byte
const long_term_fee = 10;

const utxos = [
    ...,
    {
    txId: '...',
    vout: 0,
    ...,
    value: 10000,
    script: {
            ...
        }
    }
];

const outputs = [
    ...,
    {
        address: '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm',
        value: 5000
    }
];

const { inputs, outputs, fee } = coinselection(utxos, outputs, fee_rate, long_term_fee);
```

---
_Source: https://npm.io/package/coinselection-ts · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
