From 25edc5875f06a5ac88f30a1ea106bb11fe15c487 Mon Sep 17 00:00:00 2001 From: Alessandro Rezzi Date: Mon, 14 Oct 2024 16:31:36 +0200 Subject: [PATCH] Remove blockCount dependency from Activity.vue --- scripts/dashboard/Activity.vue | 8 +------- scripts/historical_tx.js | 5 ++++- scripts/wallet.js | 7 ++++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/dashboard/Activity.vue b/scripts/dashboard/Activity.vue index 0e0386162..31ff88eac 100644 --- a/scripts/dashboard/Activity.vue +++ b/scripts/dashboard/Activity.vue @@ -12,7 +12,6 @@ import { beautifyNumber } from '../misc'; import iCheck from '../../assets/icons/icon-check.svg'; import iHourglass from '../../assets/icons/icon-hourglass.svg'; -import { blockCount } from '../global.js'; const props = defineProps({ title: String, @@ -175,11 +174,6 @@ async function parseTXs(arrTXs) { // Update the time cache prevTimestamp = cTx.time * 1000; - // Coinbase Transactions (rewards) require coinbaseMaturity confs - const fConfirmed = - blockCount - cTx.blockHeight >= - (props.rewards ? cChainParams.current.coinbaseMaturity : 6); - // Choose the content type, for the Dashboard; use a generative description, otherwise, a TX-ID // let txContent = props.rewards ? cTx.id : 'Block Reward'; @@ -248,7 +242,7 @@ async function parseTXs(arrTXs) { content: props.rewards ? cTx.id : content, formattedAmt, amount: cTx.amount, - confirmed: fConfirmed, + confirmed: cTx.isConfirmed, icon, colour, }); diff --git a/scripts/historical_tx.js b/scripts/historical_tx.js index 92883d9ef..25747b33a 100644 --- a/scripts/historical_tx.js +++ b/scripts/historical_tx.js @@ -10,6 +10,7 @@ export class HistoricalTx { * @param {number} time - The block time of the transaction. * @param {number} blockHeight - The block height of the transaction. * @param {number} amount - The amount transacted, in coins. + * @param {boolean} isConfirmed - Whether the transaction has been confirmed. */ constructor( type, @@ -18,7 +19,8 @@ export class HistoricalTx { shieldedOutputs, time, blockHeight, - amount + amount, + isConfirmed ) { this.type = type; this.id = id; @@ -27,6 +29,7 @@ export class HistoricalTx { this.time = time; this.blockHeight = blockHeight; this.amount = amount; + this.isConfirmed = isConfirmed; } } diff --git a/scripts/wallet.js b/scripts/wallet.js index 1cf95b5c8..bed6ca08d 100644 --- a/scripts/wallet.js +++ b/scripts/wallet.js @@ -666,6 +666,10 @@ export class Wallet { } else if (nAmount < 0) { type = HistoricalTxType.SENT; } + const isCoinSpecial = tx.isCoinStake() || tx.isCoinBase(); + const isConfirmed = + blockCount - tx.blockHeight >= + (isCoinSpecial ? cChainParams.current.coinbaseMaturity : 6); histTXs.push( new HistoricalTx( @@ -675,7 +679,8 @@ export class Wallet { false, tx.blockTime, tx.blockHeight, - Math.abs(nAmount) + Math.abs(nAmount), + isConfirmed ) ); }