From ed46232b837854ed6b531c774d88b72aae0657c9 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Tue, 21 Feb 2023 22:23:36 -0600 Subject: [PATCH] Fix missing fees in liquid block tooltips --- backend/src/api/blocks.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/src/api/blocks.ts b/backend/src/api/blocks.ts index 15c8590e9..8ed81016b 100644 --- a/backend/src/api/blocks.ts +++ b/backend/src/api/blocks.ts @@ -143,7 +143,10 @@ class Blocks { * @returns BlockSummary */ public summarizeBlock(block: IBitcoinApi.VerboseBlock): BlockSummary { - const stripped = block.tx.map((tx) => { + if (Common.isLiquid()) { + block = this.convertLiquidFees(block); + } + const stripped = block.tx.map((tx: IBitcoinApi.VerboseTransaction) => { return { txid: tx.txid, vsize: tx.weight / 4, @@ -158,6 +161,13 @@ class Blocks { }; } + private convertLiquidFees(block: IBitcoinApi.VerboseBlock): IBitcoinApi.VerboseBlock { + block.tx.forEach(tx => { + tx.fee = Object.values(tx.fee || {}).reduce((total, output) => total + output, 0); + }); + return block; + } + /** * Return a block with additional data (reward, coinbase, fees...) * @param block