@tokel/bitgo-komodo-cc-lib
Advanced tools
Comparing version 0.1.29 to 0.1.30
@@ -16,2 +16,3 @@ /** | ||
const types = require('../src/types'); | ||
const { decodeTransactionData, parseTransactionData } = require('./txParser') | ||
var typeforce = require('typeforce'); | ||
@@ -486,31 +487,2 @@ var typeforceNT = require('typeforce/nothrow'); | ||
/** | ||
* Decode Transaction Data into more readable format | ||
* @param {*} tx transaction to decode | ||
* @param {*} network chosen network | ||
* @returns | ||
*/ | ||
function decodeTransactionData (tx, network) { | ||
console.log(tx); | ||
const decoded = Transaction.fromHex(tx, network); | ||
console.log(decoded) | ||
return { | ||
txid: decoded.getHash().reverse().toString('hex'), | ||
ins: decoded.ins.map(one => { | ||
const txid = one.hash.reverse().toString('hex') | ||
return { | ||
...one, | ||
txid, | ||
} | ||
}), | ||
outs: decoded.outs.map(out => { | ||
return { | ||
...out, | ||
address: addresslib.fromOutputScript(out.script, network), | ||
asm: bscript.toASM(out.script), | ||
} | ||
}) | ||
} | ||
} | ||
/** | ||
* Get many transactions decoded | ||
@@ -545,5 +517,4 @@ * @param {*} peers PeerGroup obj | ||
}); | ||
decodedTxs = decodedTxs.map(tx => { | ||
return { | ||
return decodedTxs.map(tx => { | ||
const parsedTx = { | ||
...tx, | ||
@@ -557,4 +528,11 @@ ins: tx.ins.map(txin => { | ||
} | ||
}) | ||
return decodedTxs; | ||
const { recipients, senders, fees, value } = parseTransactionData(parsedTx); | ||
return { | ||
recipients, | ||
senders, | ||
fees, | ||
value, | ||
...parsedTx | ||
} | ||
}); | ||
} catch (e) { | ||
@@ -561,0 +539,0 @@ console.log(e) |
{ | ||
"name": "@tokel/bitgo-komodo-cc-lib", | ||
"version": "0.1.29", | ||
"version": "0.1.30", | ||
"description": "Client-side Bitcoin JavaScript library with Komodo cryptocondions support", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
320393
69
8619