coinselect
Advanced tools
Comparing version 1.0.1 to 2.0.0
14
index.js
@@ -10,7 +10,7 @@ // TODO: integrate privacy calculations, group by address, avoid linking multiple addresses together | ||
function estimateRelayFee (byteLength, feePerKb) { | ||
return Math.round((byteLength / 1000) * feePerKb) | ||
function estimateRelayFee (byteLength, feeRate) { | ||
return byteLength * feeRate | ||
} | ||
module.exports = function coinSelect (unspents, outputs, feePerKb) { | ||
module.exports = function coinSelect (unspents, outputs, feeRate) { | ||
// sort by descending value | ||
@@ -41,3 +41,3 @@ var sorted = unspents.concat().sort(function (o1, o2) { | ||
var baseFee = estimateRelayFee(byteLength, feePerKb) | ||
var baseFee = estimateRelayFee(byteLength, feeRate) | ||
var total = target + baseFee | ||
@@ -49,3 +49,3 @@ | ||
var feeWithChange = estimateRelayFee(byteLength + TX_OUTPUT_BASE + TX_OUTPUT_PUBKEYHASH, feePerKb) | ||
var feeWithChange = estimateRelayFee(byteLength + TX_OUTPUT_BASE + TX_OUTPUT_PUBKEYHASH, feeRate) | ||
var totalWithChange = target + feeWithChange | ||
@@ -64,2 +64,4 @@ | ||
console.log(baseFee, accum, total, remainder, feeWithChange) | ||
var remainder = accum - total | ||
@@ -75,5 +77,5 @@ | ||
return { | ||
fee: estimateRelayFee(byteLength, feePerKb), | ||
fee: estimateRelayFee(byteLength, feeRate), | ||
inputs: null | ||
} | ||
} |
{ | ||
"name": "coinselect", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "A fee optimizing bitcoin input selection module", | ||
"main": "./index.js", | ||
"scripts": { | ||
"prepublish": "npm run test", | ||
"standard": "standard", | ||
"test": "npm run-script unit", | ||
"unit": "mocha" | ||
"keywords": [ | ||
"coinselect", | ||
"coin", | ||
"unspents", | ||
"wallet", | ||
"BIP32", | ||
"management", | ||
"utxo", | ||
"transaction", | ||
"fee", | ||
"optimization", | ||
"optimizing", | ||
"bitcoin" | ||
], | ||
"homepage": "https://github.com/dcousens/coinselect", | ||
"bugs": { | ||
"url": "https://github.com/dcousens/coinselect/issues" | ||
}, | ||
"license": "MIT", | ||
"author": "Daniel Cousens", | ||
"files": [ | ||
"index.js" | ||
], | ||
"main": "index.js", | ||
"repository": { | ||
@@ -16,14 +33,14 @@ "type": "git", | ||
}, | ||
"author": "Daniel Cousens", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/dcousens/coinselect/issues" | ||
"scripts": { | ||
"prepublish": "npm run test", | ||
"coverage": "nyc --check-coverage --branches 100 --functions 100 tape test/*.js", | ||
"lint": "standard", | ||
"test": "npm run lint && npm run unit", | ||
"unit": "tape test/*.js" | ||
}, | ||
"homepage": "https://github.com/dcousens/coinselect", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"mocha": "*", | ||
"sinon": "^1.12.0", | ||
"standard": "*" | ||
"nyc": "^6.4.0", | ||
"standard": "*", | ||
"tape": "^4.5.1" | ||
} | ||
} |
@@ -22,3 +22,3 @@ # coinselect | ||
var feePerKb = 1000 | ||
var feeRate = 55 | ||
var unspents = [ | ||
@@ -39,3 +39,3 @@ ..., | ||
var result = coinselect(unspents, outputs, feePerKb) | ||
var result = coinselect(unspents, outputs, feeRate) | ||
@@ -42,0 +42,0 @@ // the accumulated fee is always returned |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5283
4
58
1