Skip to content

Commit

Permalink
Merge pull request #16 from getsafle/bugfix-utxo-calc
Browse files Browse the repository at this point in the history
UTXO calculation fix
  • Loading branch information
apoorvq authored Sep 16, 2022
2 parents fdcb29e + 812d9e4 commit 5b40ec2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@

##### UTXO calculation fix

- UTXO.satoshi calculation fix.
- UTXO.satoshi calculation fix.

### 1.2.3 (2022-09-16)

##### UTXO calculation fix

- UTXO.satoshi calculation and adding package `satoshi-bitcoin`.
17 changes: 15 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@getsafle/vault-bitcoin-controller",
"version": "1.2.2",
"version": "1.2.3",
"description": "",
"engines": {
"node": ">= 10"
Expand Down Expand Up @@ -31,7 +31,8 @@
"bitcoinjs-lib": "^5.2.0",
"bitcoinjs-message": "^2.2.0",
"bitcore-lib": "^8.25.10",
"obs-store": "^4.0.3"
"obs-store": "^4.0.3",
"satoshi-bitcoin": "^1.0.5"
},
"devDependencies": {
"@metamask/eslint-config": "^4.0.0",
Expand All @@ -41,4 +42,4 @@
"eslint-plugin-node": "^11.1.0",
"mocha": "^8.1.3"
}
}
}
3 changes: 2 additions & 1 deletion src/helper/calculateFeeAndInput.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const axios = require('axios')
var sb = require("satoshi-bitcoin");
const { SATOSHI } = require("../config/index")

async function getFeeAndInput(URL, satPerByte) {
Expand All @@ -13,7 +14,7 @@ async function getFeeAndInput(URL, satPerByte) {
let inputs = [];
utxos.data.data.txs.forEach(async (element) => {
let utxo = {};
utxo.satoshis = Math.ceil(parseFloat(element.value) * SATOSHI);
utxo.satoshis = sb.toSatoshi(parseFloat(element.value));
utxo.script = element.script_hex;
utxo.address = utxos.data.data.address;
utxo.txId = element.txid;
Expand Down

0 comments on commit 5b40ec2

Please sign in to comment.