Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@bitgo/unspents

BitGo14kApache-2.00.47.21TypeScript support: included

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

bitcoin, utxo

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

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 github actions for continuous integration, which is configured by the .github/workflows/ci.yml file in the project root. All changes to the CI process should be done by modifying the .github/workflows/ci.yml file.

Codes

The exported Codes module is now deprecated.

Please use utxo-lib/src/bitgo/wallet/chains instead.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.47.21 (2025-04-04)

Note: Version bump only for package @bitgo/unspents

0.47.20 (2025-03-04)

Note: Version bump only for package @bitgo/unspents

0.47.19 (2025-02-26)

Note: Version bump only for package @bitgo/unspents

0.47.18 (2025-02-19)

Note: Version bump only for package @bitgo/unspents

0.47.17 (2024-12-03)

Note: Version bump only for package @bitgo/unspents

0.47.16 (2024-11-26)

Note: Version bump only for package @bitgo/unspents

0.47.15 (2024-11-21)

Note: Version bump only for package @bitgo/unspents

0.47.14 (2024-11-19)

Note: Version bump only for package @bitgo/unspents

0.47.13 (2024-11-14)

Note: Version bump only for package @bitgo/unspents

0.47.12 (2024-11-01)

Note: Version bump only for package @bitgo/unspents

0.47.11 (2024-10-04)

Note: Version bump only for package @bitgo/unspents

0.47.10 (2024-09-03)

Note: Version bump only for package @bitgo/unspents

0.47.9 (2024-08-27)

Note: Version bump only for package @bitgo/unspents

0.47.8 (2024-08-07)

Note: Version bump only for package @bitgo/unspents

0.47.7 (2024-07-16)

Note: Version bump only for package @bitgo/unspents

0.47.6 (2024-07-04)

Note: Version bump only for package @bitgo/unspents

0.47.5 (2024-06-26)

Note: Version bump only for package @bitgo/unspents

0.47.4 (2024-06-11)

Note: Version bump only for package @bitgo/unspents

0.47.3 (2024-05-08)

Note: Version bump only for package @bitgo/unspents

0.47.2 (2024-05-01)

Note: Version bump only for package @bitgo/unspents

0.47.1 (2024-04-22)

Note: Version bump only for package @bitgo/unspents

0.47.0 (2024-04-10)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.45.0 (2024-01-30)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.44.0 (2024-01-26)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.43.0 (2024-01-26)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.42.0 (2024-01-25)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.41.0 (2024-01-22)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.40.0 (2024-01-09)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.39.0 (2024-01-03)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.38.0 (2023-12-18)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.37.0 (2023-12-12)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.36.0 (2023-12-09)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.35.0 (2023-12-05)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.34.0 (2023-11-28)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.33.0 (2023-11-24)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.32.0 (2023-11-17)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: default unspents dimensions to recovery path (361eb62)
  • unspents: extend tests (aec14ec)

0.31.0 (2023-11-13)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.30.0 (2023-11-13)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.29.0 (2023-11-13)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.28.0 (2023-10-20)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.27.0 (2023-10-18)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.26.0 (2023-09-25)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.25.0 (2023-09-09)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.24.0 (2023-09-09)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.23.0 (2023-09-07)

Bug Fixes

  • root: update @types/node (cedc1a0)
  • unspents: move --recursive flag to mocha (275b8fb)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)
  • unspents: add test for finding feePerKB (f6397d7)
  • unspents: add ZCash ZIP-0317 fee calculation (8c86f8f)
  • unspents: extend tests (aec14ec)

0.22.0 (2023-09-05)

Bug Fixes

  • root: update @types/node (cedc1a0)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)

0.21.0 (2023-09-01)

Bug Fixes

  • root: update @types/node (cedc1a0)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)

0.20.0 (2023-08-29)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)

0.19.0 (2023-08-25)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)

0.18.0 (2023-08-24)

Features

  • sdk-api: add size correction factor for transactions created (5f0131c)

0.17.2 (2023-08-16)

Note: Version bump only for package @bitgo/unspents

0.17.1 (2023-08-16)

Note: Version bump only for package @bitgo/unspents

0.17.0 (2023-08-04)

Features

  • unspents: add docs/input-costs.md, generation tool (aa843da)
  • unspents: fix unspents module setup (687f4c3), closes #3651

0.16.0 (2023-07-28)

Features

  • unspents: add docs/input-costs.md, generation tool (aa843da)
  • unspents: fix unspents module setup (687f4c3), closes #3651

0.15.4 (2023-07-18)

Note: Version bump only for package @bitgo/unspents

0.15.3 (2023-06-21)

Note: Version bump only for package @bitgo/unspents

0.15.2 (2023-06-13)

Note: Version bump only for package @bitgo/unspents

0.15.1 (2023-06-07)

Note: Version bump only for package @bitgo/unspents

0.15.0 (2023-06-05)

Bug Fixes

  • utxo-lib: use PsbtInput instead of UtxoPsbt (1f73539)

BREAKING CHANGES

  • utxo-lib: functions signature is changed

0.14.2 (2023-05-25)

Note: Version bump only for package @bitgo/unspents

0.14.1 (2023-05-17)

Bug Fixes

  • bitgo: drone is no longer used in this repo so can safely be removed (badc0de), closes #3554 #3554

0.14.0 (2023-05-10)

Features

  • utxo-lib: add musig2 nonce at input index (9991d3f)

0.13.2 (2023-05-03)

Note: Version bump only for package @bitgo/unspents

0.13.1 (2023-04-25)

Note: Version bump only for package @bitgo/unspents

0.13.0 (2023-04-20)

Features

  • unspents: unsigned psbt dimensions can be calculated (427cc36)

0.12.0 (2023-04-13)

Features

  • unspents: add dimensions for psbt (b125034)
  • unspents: add p2trMusig2 to dimensions (de460ad)
  • utxo-lib: create p2tr address using musig2 (699e829)
  • utxo-lib: create p2trMusig2 nonce using derived key (a0cd1f1)
  • utxo-lib: introduce ParsedScriptType (3c28bbc)
  • utxo-lib: parse p2trMusig2 key path witness (ecb4c31)

0.11.12 (2023-02-16)

Note: Version bump only for package @bitgo/unspents

0.11.11 (2023-02-08)

Note: Version bump only for package @bitgo/unspents

0.11.10 (2023-01-30)

Note: Version bump only for package @bitgo/unspents

0.11.9 (2023-01-25)

Note: Version bump only for package @bitgo/unspents

0.11.8 (2022-12-23)

Note: Version bump only for package @bitgo/unspents

0.11.7 (2022-12-20)

Note: Version bump only for package @bitgo/unspents

0.11.6 (2022-12-06)

Note: Version bump only for package @bitgo/unspents

0.11.5 (2022-11-29)

Note: Version bump only for package @bitgo/unspents

0.11.4 (2022-11-04)

Note: Version bump only for package @bitgo/unspents

0.11.2 (2022-10-27)

Note: Version bump only for package @bitgo/unspents

0.11.1 (2022-10-25)

Note: Version bump only for package @bitgo/unspents

0.11.0 (2022-10-18)

Bug Fixes

  • core: fix bip32/ecpair, API vs Interface (bec9c1e)
  • root: align versions of bitcoinjs-lib (b7eb929)
  • unspents: remove bitcoinjs-lib.d.ts (e4447d4)
  • unspents: use new bip32/BIP32Interface in tests (9de0c78)

Features

  • update to work with bitcoinjs-lib@6 (1950934)
  • utxo-lib: export BIP32/ECPair interfaces (8628507)

0.8.3 (2022-07-19)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.15 (2022-07-11)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.14 (2022-06-23)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.13 (2022-06-22)

Bug Fixes

  • add dependency check to fix current and future dependency resolutions (3074335)

0.8.0-rc.12 (2022-06-16)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.11 (2022-06-13)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.10 (2022-06-07)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.9 (2022-06-01)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.8 (2022-05-17)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.7 (2022-05-16)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.6 (2022-05-12)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.3 (2022-04-19)

Note: Version bump only for package @bitgo/unspents

0.7.4 (2022-04-06)

Note: Version bump only for package @bitgo/unspents

0.7.3 (2022-04-05)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.2 (2022-04-05)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.3 (2022-04-05)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.2 (2022-04-05)

Note: Version bump only for package @bitgo/unspents

0.8.0-rc.2 (2022-04-05)

Note: Version bump only for package @bitgo/unspents