diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index feb02f1ca..a0a8e8494 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -76,7 +76,7 @@ class Blocks { block.coinbaseTx = this.stripCoinbaseTransaction(transactions[0]); transactions.sort((a, b) => b.feePerVsize - a.feePerVsize); block.medianFee = transactions.length > 1 ? Common.median(transactions.map((tx) => tx.feePerVsize)) : 0; - block.feeRange = transactions.length > 1 ? Common.getFeesInRange(transactions, 8, 1) : [0, 0]; + block.feeRange = transactions.length > 1 ? Common.getFeesInRange(transactions.slice(0, transactions.length - 2), 8) : [0, 0]; this.blocks.push(block); if (this.blocks.length > config.KEEP_BLOCK_AMOUNT) { diff --git a/backend/src/api/common.ts b/backend/src/api/common.ts index c3e0f1a42..04fd6e2ce 100644 --- a/backend/src/api/common.ts +++ b/backend/src/api/common.ts @@ -12,7 +12,7 @@ export class Common { return medianNr; } - static getFeesInRange(transactions: TransactionExtended[], rangeLength: number, lastindex = 0) { + static getFeesInRange(transactions: TransactionExtended[], rangeLength: number) { const arr = [transactions[transactions.length - 1].feePerVsize]; const chunk = 1 / (rangeLength - 1); let itemsToAdd = rangeLength - 2; @@ -22,7 +22,7 @@ export class Common { itemsToAdd--; } - arr.push(transactions[lastindex].feePerVsize); + arr.push(transactions[0].feePerVsize); return arr; } diff --git a/backend/src/api/mempool.ts b/backend/src/api/mempool.ts index 05d310462..c8febcd5b 100644 --- a/backend/src/api/mempool.ts +++ b/backend/src/api/mempool.ts @@ -77,7 +77,7 @@ class Mempool { const transaction: Transaction = await bitcoinApi.getRawTransaction(txId); return Object.assign({ vsize: transaction.weight / 4, - feePerVsize: transaction.fee / (transaction.weight / 4), + feePerVsize: (transaction.fee || 0) / (transaction.weight / 4), firstSeen: Math.round((new Date().getTime() / 1000)), }, transaction); } catch (e) { diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index d71f87031..259a003c5 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -74,6 +74,9 @@ export class TransactionComponent implements OnInit, OnDestroy { return; } this.tx = tx; + if (tx.fee === undefined) { + this.tx.fee = 0; + } this.isLoadingTx = false; this.error = undefined; this.waitingForTransaction = false;