{"_id":"@ar-packages-changeit/bitcoin-utxo-selection","_rev":"2-cfd9227e6c12b12dc4d9675364144e77","name":"@ar-packages-changeit/bitcoin-utxo-selection","dist-tags":{"develop":"2.0.2-7bc25721","latest":"2.0.2"},"versions":{"2.0.2-7bc25721":{"name":"@ar-packages-changeit/bitcoin-utxo-selection","version":"2.0.2-7bc25721","author":{"name":"Rosen Team"},"license":"MIT","_id":"@ar-packages-changeit/bitcoin-utxo-selection@2.0.2-7bc25721","maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"homepage":"https://github.com/rosen-bridge/selection#readme","bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"dist":{"shasum":"a5dc8b379a76108d84f2b835c35d720de7743056","tarball":"https://registry.npmjs.org/@ar-packages-changeit/bitcoin-utxo-selection/-/bitcoin-utxo-selection-2.0.2-7bc25721.tgz","fileCount":15,"integrity":"sha512-J3QNY0SbDkPtQzt3B/9Mkbk3/6IbzdPT9Spqgl7BdONI0yMfGc2gtf4s3fBuWKJW1lHVzQze8RURQcRtNXmBew==","signatures":[{"sig":"MEUCICZctMfv+ZqEQgIdxFDLe6iB+m57wRpNU+hm+VOUc6oZAiEA/PvHk+8r/HNi/wZ54yMEYeAZNqQH6wqfzfKUUhZANms=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15730},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=22.18.0"},"gitHead":"7bc25721f554f9b4be8b1c1599b621955c6dbb6c","scripts":{"lint":"eslint --fix . && npm run prettify","test":"NODE_OPTIONS='--import tsx' vitest","build":"tsc --build tsconfig.build.json","clean":"rimraf dist && rimraf tsconfig.build.tsbuildinfo","release":"npm run clean && npm run build && npm run test -- --run && npm publish --access public","coverage":"npm run test -- --run --coverage","prettify":"prettier --write . --ignore-path ../../.gitignore","lint:check":"eslint . && npm run prettify:check","type-check":"tsc --noEmit","prettify:check":"prettier --check . --ignore-path ../../.gitignore"},"_npmUser":{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"},"repository":{"url":"git+https://github.com/rosen-bridge/selection.git","type":"git"},"_npmVersion":"11.6.2","description":"A Typescript package to select enough Bitcoin utxos for required amount of BTC","directories":{},"_nodeVersion":"22.18.0","dependencies":{"@rosen-bridge/selection-types":"^1.0.1","@rosen-bridge/abstract-box-selection":"^1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.5","vitest":"^3.1.4","@vitest/coverage-istanbul":"^3.1.4"},"_npmOperationalInternal":{"tmp":"tmp/bitcoin-utxo-selection_2.0.2-7bc25721_1763557933191_0.3771694689590359","host":"s3://npm-registry-packages-npm-production"}},"2.0.2":{"name":"@ar-packages-changeit/bitcoin-utxo-selection","version":"2.0.2","description":"A Typescript package to select enough Bitcoin utxos for required amount of BTC","repository":{"type":"git","url":"git+https://github.com/rosen-bridge/selection.git"},"license":"MIT","author":{"name":"Rosen Team"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc --build tsconfig.build.json","clean":"rimraf dist && rimraf tsconfig.build.tsbuildinfo","coverage":"npm run test -- --run --coverage","lint":"eslint --fix . && npm run prettify","lint:check":"eslint . && npm run prettify:check","prettify":"prettier --write . --ignore-path ../../.gitignore","prettify:check":"prettier --check . --ignore-path ../../.gitignore","release":"npm run clean && npm run build && npm run test -- --run && npm publish --access public","test":"NODE_OPTIONS='--import tsx' vitest","type-check":"tsc --noEmit"},"dependencies":{"@rosen-bridge/abstract-box-selection":"^1.0.1","@rosen-bridge/selection-types":"^1.0.1"},"devDependencies":{"@vitest/coverage-istanbul":"^3.1.4","tsx":"^4.20.5","vitest":"^3.1.4"},"engines":{"node":">=22.18.0"},"gitHead":"fc55a043c8019b3f18d0c1a033f12d43a4693458","_id":"@ar-packages-changeit/bitcoin-utxo-selection@2.0.2","bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"homepage":"https://github.com/rosen-bridge/selection#readme","_nodeVersion":"22.18.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-y1PdBmsyJe1njSmnPzlXhKKlhbmLkMYbjq3FS5maI7mF+VdQohR3QfgMrgy/f2yCifK40BpgMusg0euJ2L7Krg==","shasum":"abdfdaee1486d6e7f5c168a4b8f509d47ff6f035","tarball":"https://registry.npmjs.org/@ar-packages-changeit/bitcoin-utxo-selection/-/bitcoin-utxo-selection-2.0.2.tgz","fileCount":16,"unpackedSize":69288,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDP1f5LcRDr/ZxK37G04qwY+Da3a/+JGcdXRjId+8AADwIgCEyYL8OtTMGQzaMZAPLIUac4yGiML3rXPmMUN/Y11yY="}]},"_npmUser":{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"},"directories":{},"maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/bitcoin-utxo-selection_2.0.2_1763558449631_0.5550194973700244"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-19T13:12:13.098Z","modified":"2025-11-19T13:20:50.035Z","2.0.2-7bc25721":"2025-11-19T13:12:13.380Z","2.0.2":"2025-11-19T13:20:49.820Z"},"bugs":{"url":"https://github.com/rosen-bridge/selection/issues"},"author":{"name":"Rosen Team"},"license":"MIT","homepage":"https://github.com/rosen-bridge/selection#readme","repository":{"type":"git","url":"git+https://github.com/rosen-bridge/selection.git"},"description":"A Typescript package to select enough Bitcoin utxos for required amount of BTC","maintainers":[{"name":"arsalanyavari","email":"arya48.yavari79@gmail.com"}],"readme":"# @rosen-bridge/bitcoin-utxo-selection\n\n## Table of contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n\n## Introduction\n\nA TypeScript package for selecting Bitcoin UTXOs to cover required amounts of BTC and fees, built on top of the abstract box selection framework.\n\n## Installation\n\nnpm:\n\n```sh\nnpm i @rosen-bridge/bitcoin-utxo-selection\n```\n\nyarn:\n\n```sh\nyarn add @rosen-bridge/bitcoin-utxo-selection\n```\n\n## Usage\n\nHere's a basic example of how to use this package:\n\n```typescript\nimport { DummyLogger } from '@rosen-bridge/abstract-logger';\nimport { BitcoinBoxSelection } from '@rosen-bridge/bitcoin-utxo-selection';\n\n// Create a fee estimator\n// An example fee estimator for a transaction with only native-segwit inputs and outputs and 3 fee ratio\nconst feeEstimator = BitcoinBoxSelection.generateFeeEstimator(\n  1, // additional output count\n  42, // tx base weight\n  272, // input weight unit\n  124, // output weight unit\n  3, // fee ratio (in satoshis per byte)\n  4, // discount factor\n);\n\n// Create the selection instance\nconst selector = new BitcoinBoxSelection(new DummyLogger());\n\n// Define required assets\nconst requiredAssets = {\n  nativeToken: 6000000n, // 0.06 BTC\n  tokens: [],\n};\n\n// Define UTXOs\nconst utxos: BitcoinUtxo[] = [\n  { txId: 'tx1', index: 0, value: 5000000 }, // 0.05 BTC\n  { txId: 'tx2', index: 0, value: 3000000 }, // 0.03 BTC\n  { txId: 'tx3', index: 0, value: 2000000 }, // 0.02 BTC\n];\n\n// Get covering boxes\nconst result = await selector.getCoveringBoxes(\n  requiredAssets,\n  [], // forbidden box IDs\n  new Map(), // track map\n  utxos.values(),\n  294n, // min box value\n  undefined, // max token count (does not matter on Bitcoin, but still cannot be 0)\n  feeEstimator,\n);\n\nif (result.covered) {\n  console.log('Selected UTXOs:', result.boxes);\n  console.log('Additional assets:', result.additionalAssets);\n} else {\n  console.log('Could not cover requirements');\n}\n```\n","readmeFilename":"README.md"}