{"_id":"@1tokenfe/coinselect","name":"@1tokenfe/coinselect","dist-tags":{"latest":"3.1.14"},"versions":{"3.1.14":{"name":"@1tokenfe/coinselect","version":"3.1.14","description":"A transaction input selection module for bitcoin.","keywords":["coinselect","coin","unspents","wallet","BIP32","management","utxo","transaction","fee","optimization","optimizing","bitcoin"],"homepage":"https://github.com/bitcoinjs/coinselect","bugs":{"url":"https://github.com/bitcoinjs/coinselect/issues"},"license":"MIT","author":{"name":"Daniel Cousens"},"main":"index.js","types":"index.d.ts","repository":{"type":"git","url":"git+https://github.com/bitcoinjs/coinselect.git"},"scripts":{"coverage":"nyc --exclude='third-party/**' --check-coverage --branches 90 --functions 95 tape test/*.js","standard":"standard","standard:file":"standard --fix","test":"npm run standard && npm run unit","unit":"tape test/*.js","test-witness":"tape test/witness.js"},"devDependencies":{"nyc":"^15.0.0","standard":"17.1.2","tape":"^4.5.1"},"dependencies":{"bchaddrjs":"^0.5.2","bech32":"^2.0.0","bip66":"^2.0.0","bitcoin-ops":"^1.4.1","blake-hash":"^2.0.0","blakejs":"^1.2.1","bn.js":"^5.2.1","bs58":"^6.0.0","bs58check":"^4.0.0","create-hmac":"^1.1.7","int64-buffer":"^1.0.1","pushdata-bitcoin":"^1.0.1","tiny-secp256k1":"^1.1.6","typeforce":"^1.18.0","varuint-bitcoin":"2.0.0","wif":"^5.0.0","bignumber.js":"9.1.2"},"peerDependencies":{"tslib":"^2.6.2"},"standard":{"ignore":["third-party/**"]},"_id":"@1tokenfe/coinselect@3.1.14","gitHead":"db821cbe4abf5a5a115536d04c2df1179ad2fe5a","_nodeVersion":"20.18.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-lSmptha4PIaQw0ItDTYDNSk1qFmjSQFqclld9h26HNcnbh7dlZwOmrBCmUSPveDqjTxVLeAFrFvEYwycjyZ03g==","shasum":"8f84c9ade2c53a9dae0b3121ddfd90884fefe827","tarball":"https://registry.npmjs.org/@1tokenfe/coinselect/-/coinselect-3.1.14.tgz","fileCount":229,"unpackedSize":298181,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCTEfmw9cRTGVm90XuqJ+0A6+E2Gq3E+cpxUBzDuw4O7gIhAI84fEIOaKIq1IRu8ZWjJrzv3h1qGouiwFMWmnthS1CN"}]},"_npmUser":{"name":"dihuase0411","email":"dihuase0411@gmail.com"},"directories":{},"maintainers":[{"name":"vici1573","email":"vici1573@outlook.com"},{"name":"onetokenwallet","email":"yf860412@gmail.com"},{"name":"dihuase0411","email":"dihuase0411@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/coinselect_3.1.14_1763435858587_0.33412090833085695"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-18T03:17:38.507Z","3.1.14":"2025-11-18T03:17:38.799Z","modified":"2025-11-18T03:17:39.169Z"},"maintainers":[{"name":"vici1573","email":"vici1573@outlook.com"},{"name":"onetokenwallet","email":"yf860412@gmail.com"},{"name":"dihuase0411","email":"dihuase0411@gmail.com"}],"description":"A transaction input selection module for bitcoin.","homepage":"https://github.com/bitcoinjs/coinselect","keywords":["coinselect","coin","unspents","wallet","BIP32","management","utxo","transaction","fee","optimization","optimizing","bitcoin"],"repository":{"type":"git","url":"git+https://github.com/bitcoinjs/coinselect.git"},"author":{"name":"Daniel Cousens"},"bugs":{"url":"https://github.com/bitcoinjs/coinselect/issues"},"license":"MIT","readme":"# coinselect\n\n[![TRAVIS](https://secure.travis-ci.org/bitcoinjs/coinselect.png)](http://travis-ci.org/bitcoinjs/coinselect)\n[![NPM](http://img.shields.io/npm/v/coinselect.svg)](https://www.npmjs.org/package/coinselect)\n\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\nAn unspent transaction output (UTXO) selection module for bitcoin.\n\n**WARNING:** Value units are in `satoshi`s, **not** Bitcoin.\n\n\n## Algorithms\nModule | Algorithm | Re-orders UTXOs?\n-|-|-\n`require('coinselect')` | Blackjack, with Accumulative fallback | By Descending Value\n`require('coinselect/accumulative')` | Accumulative - accumulates inputs until the target value (+fees) is reached, skipping detrimental inputs | -\n`require('coinselect/blackjack')` | Blackjack - accumulates inputs until the target value (+fees) is matched, does not accumulate inputs that go over the target value (within a threshold) | -\n`require('coinselect/break')` | Break - breaks the input values into equal denominations of `output` (as provided) | -\n`require('coinselect/split')` | Split - splits the input values evenly between all `outputs`, any provided `output` with `.value` remains unchanged | -\n\n\n**Note:** Each algorithm will add a change output if the `input - output - fee` value difference is over a dust threshold.\nThis is calculated independently by `utils.finalize`, irrespective of the algorithm chosen, for the purposes of safety.\n\n**Pro-tip:** if you want to send-all inputs to an output address, `coinselect/split` with a partial output (`.address` defined, no `.value`) can be used to send-all, while leaving an appropriate amount for the `fee`. \n\n## Example\n\n``` javascript\nlet coinSelect = require('coinselect')\nlet feeRate = 55 // satoshis per byte\nlet utxos = [\n  ...,\n  {\n    txId: '...',\n    vout: 0,\n    ...,\n    value: 10000,\n    // For use with PSBT:\n    // not needed for coinSelect, but will be passed on to inputs later\n    nonWitnessUtxo: Buffer.from('...full raw hex of txId tx...', 'hex'),\n    // OR\n    // if your utxo is a segwit output, you can use witnessUtxo instead\n    witnessUtxo: {\n      script: Buffer.from('... scriptPubkey hex...', 'hex'),\n      value: 10000 // 0.0001 BTC and is the exact same as the value above\n    }\n  }\n]\nlet targets = [\n  ...,\n  {\n    address: '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm',\n    value: 5000\n  }\n]\n\n// ...\nlet { inputs, outputs, fee } = coinSelect(utxos, targets, feeRate)\n\n// the accumulated fee is always returned for analysis\nconsole.log(fee)\n\n// .inputs and .outputs will be undefined if no solution was found\nif (!inputs || !outputs) return\n\nlet psbt = new bitcoin.Psbt()\n\ninputs.forEach(input =>\n  psbt.addInput({\n    hash: input.txId,\n    index: input.vout,\n    nonWitnessUtxo: input.nonWitnessUtxo,\n    // OR (not both)\n    witnessUtxo: input.witnessUtxo,\n  })\n)\noutputs.forEach(output => {\n  // watch out, outputs may have been added that you need to provide\n  // an output address/script for\n  if (!output.address) {\n    output.address = wallet.getChangeAddress()\n    wallet.nextChangeAddress()\n  }\n\n  psbt.addOutput({\n    address: output.address,\n    value: output.value,\n  })\n})\n```\n\n\n## License [MIT](LICENSE)\n","readmeFilename":"README.md","_rev":"1-97707c7853f8127e596fbc97d9f7d3d3"}