mirror of
https://github.com/mempool/mempool.git
synced 2025-03-30 04:32:06 +02:00
Fix transaction size when using esplora api
This commit is contained in:
parent
35c4d9676c
commit
3074983d3a
@ -43,8 +43,7 @@ class EsploraApi implements AbstractBitcoinApi {
|
|||||||
try {
|
try {
|
||||||
const response: AxiosResponse = await this.client.get('/tx/' + txId);
|
const response: AxiosResponse = await this.client.get('/tx/' + txId);
|
||||||
|
|
||||||
response.data.vsize = response.data.size;
|
response.data.vsize = Math.round(response.data.weight / 4);
|
||||||
response.data.size = response.data.weight;
|
|
||||||
response.data.fee = response.data.fee / 100000000;
|
response.data.fee = response.data.fee / 100000000;
|
||||||
response.data.blockhash = response.data.status.block_hash;
|
response.data.blockhash = response.data.status.block_hash;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class Mempool {
|
|||||||
transaction.vout.forEach((output) => totalOut += output.value);
|
transaction.vout.forEach((output) => totalOut += output.value);
|
||||||
|
|
||||||
if (config.BACKEND_API === 'esplora') {
|
if (config.BACKEND_API === 'esplora') {
|
||||||
transaction.feePerWeightUnit = (transaction.fee * 100000000) / (transaction.vsize * 4) || 0;
|
transaction.feePerWeightUnit = (transaction.fee * 100000000) / transaction.weight || 0;
|
||||||
transaction.feePerVsize = (transaction.fee * 100000000) / (transaction.vsize) || 0;
|
transaction.feePerVsize = (transaction.fee * 100000000) / (transaction.vsize) || 0;
|
||||||
transaction.totalOut = totalOut / 100000000;
|
transaction.totalOut = totalOut / 100000000;
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,7 +54,7 @@ class ProjectedBlocks {
|
|||||||
let transactions: ITransaction[] = [];
|
let transactions: ITransaction[] = [];
|
||||||
this.transactionsSorted.forEach((tx) => {
|
this.transactionsSorted.forEach((tx) => {
|
||||||
if (blockWeight + tx.vsize * 4 < 4000000 || projectedBlocks.length === numberOfBlocks) {
|
if (blockWeight + tx.vsize * 4 < 4000000 || projectedBlocks.length === numberOfBlocks) {
|
||||||
blockWeight += tx.vsize * 4;
|
blockWeight += tx.weight || tx.vsize * 4;
|
||||||
blockSize += tx.size;
|
blockSize += tx.size;
|
||||||
transactions.push(tx);
|
transactions.push(tx);
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,6 +13,7 @@ export interface ITransaction {
|
|||||||
version: number;
|
version: number;
|
||||||
size: number;
|
size: number;
|
||||||
vsize: number;
|
vsize: number;
|
||||||
|
weight: number;
|
||||||
locktime: number;
|
locktime: number;
|
||||||
vin: Vin[];
|
vin: Vin[];
|
||||||
vout: Vout[];
|
vout: Vout[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user