blob: 26ade9dac190b59639c3f9787116c839b37c91e1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
module.exports = async (txid) => {
const tx = await bc.getRawTransaction(txid);
const transaction = await bc.decodeRawTransaction(tx);
let valueIn = 0;
let valueOut = 0;
const txVin = await Promise.all(
transaction.vin.map(async o =>
await bc.decodeRawTransaction(
await bc.getRawTransaction(o.txid)
)
)
);
txVin.forEach(o => o.vout.forEach(o => valueIn += o.value));
transaction.vout.forEach(o => valueOut += o.value);
return toSats(valueIn - valueOut);
}
|