# @bitgo-beta/unspents

> Defines the chain codes used for different unspent types and methods to calculate bitcoin transaction sizes

Latest version **0.8.3** (published 2022-09-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @bitgo-beta/unspents
pnpm add @bitgo-beta/unspents
yarn add @bitgo-beta/unspents
bun add @bitgo-beta/unspents
```

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.8.3 |
| Published | 2022-09-29 |
| First published | 2022-09-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 65.7 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 395 |
| Author | BitGo SDK Team |
| Maintainers | bitgoaaron |
| Keywords | bitcoin, utxo |

## Links

- npm: https://www.npmjs.com/package/@bitgo-beta/unspents
- Repository: https://github.com/BitGo/BitGoJS
- Homepage: https://github.com/BitGo/BitGoJS/tree/master/modules/unspents#bitgounspents
- Issues: https://github.com/BitGo/BitGoJS/issues
- npm.io page: https://npm.io/package/@bitgo-beta/unspents

## Dependencies (4)

- [tcomb](https://npm.io/package/tcomb.md) ~3.2.29
- [lodash](https://npm.io/package/lodash.md) ~4.17.21
- [varuint-bitcoin](https://npm.io/package/varuint-bitcoin.md) ^1.0.4
- [@bitgo-beta/utxo-lib](https://npm.io/package/@bitgo-beta/utxo-lib.md) ^2.4.1

## Recent versions

- 0.8.3 (latest) — 2022-09-29
- 0.13.2-beta.2141 (beta) — 2026-10-22
- 0.11.3-alpha.513 (alpha) — 2026-08-05
- 0.13.2-beta.2140 — 2026-10-21
- 0.13.2-beta.2139 — 2026-10-21
- 0.13.2-beta.2138 — 2026-10-21
- 0.13.2-beta.2137 — 2026-10-21
- 0.13.2-beta.2136 — 2026-10-21
- 0.13.2-beta.2135 — 2026-10-21
- 0.13.2-beta.2134 — 2026-10-19
- 0.13.2-beta.2133 — 2026-10-19
- 0.13.2-beta.2132 — 2026-10-17
- 0.13.2-beta.2131 — 2026-10-17
- 0.13.2-beta.2130 — 2026-10-17
- 0.13.2-beta.2129 — 2026-10-17
- … 2882 more at https://npm.io/package/@bitgo-beta/unspents/versions

## README

# @bitgo/unspents

The package provides a `Dimensions` class with methods to calculate bitcoin transaction sizes

## Installation

```
npm install --save @bitgo/unspents
```

## Dimensions, Virtual Size Estimation

The transaction vSize is critical to calculating the proper transaction fee.

The class `unspents.Dimensions` provides a class that helps work with the components required
to calculate an accurate estimate of a transaction vSize.

### Examples

```typescript
import { Codes, Dimensions } from '@bitgo/unspents';
// using raw attributes
new Dimensions({
  nP2shInputs: 1,
  nP2shP2wshInputs: 1,
  nP2wshInputs: 1,
  outputs: { count: 1, size: 32 },
});

// calculate from unspents that have `chain` property (see Chain Codes)
Dimensions.fromUnspents(unspent[0]);
Dimensions.fromUnspents(unspents);

// Signed inputs work too
Dimensions.fromInput(inputs[0]);
Dimensions.fromInputs(inputs);

// Transaction outputs
Dimensions.fromOutputs(outputs[0]);
Dimensions.fromOutputs(outputs);
Dimensions.fromOutputOnChain(Codes.p2sh.internal);
Dimensions.fromOutputScriptLength(31);

// Combining dimensions and estimating their vSize
Dimensions.fromUnspents({ unspents })
  .plus(Dimensions.fromOutputOnChain(Codes.p2shP2wsh.internal).times(nOutputs))
  .getVSize();
```

## Publishing new versions

Publishing new versions should be done by running the publish script in `scripts/publish.sh`.

It can be invoked with the name of the branch to release, and will default to the currently checked out branch if not given.

It will perform validation of all prepublish conditions, run a dry-run publish, then, if successful, a real publish. After that is complete,
the newly installed package will be downloaded and `require()`'d to ensure the package was published correctly.

## Continuous Integration

`@bitgo/unspents` uses Drone for continuous integration, which is configured by the `.drone.yml` file in the project root. However, this file should not be modified by hand. All changes to the CI process should be done by modifying the `.drone.jsonnet` file, then running `npm run generate_drone` to rebuild the `.drone.yml` file.

## `Codes`

The exported `Codes` module is now deprecated.

Please use [`utxo-lib/src/bitgo/wallet/chains`](https://github.com/BitGo/BitGoJS/blob/0439a0d4ffe4a15a9932ed70f98cc5745cc6526f/modules/utxo-lib/src/bitgo/wallet/chains.ts) instead.

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