diff --git a/backend/src/api/bitcoin/bitcoin.routes.ts b/backend/src/api/bitcoin/bitcoin.routes.ts index 2d5077bc4..c6323d041 100644 --- a/backend/src/api/bitcoin/bitcoin.routes.ts +++ b/backend/src/api/bitcoin/bitcoin.routes.ts @@ -220,18 +220,17 @@ class BitcoinRoutes { let cpfpInfo; if (config.DATABASE.ENABLED) { cpfpInfo = await transactionRepository.$getCpfpInfo(req.params.txId); + } + if (cpfpInfo) { + res.json(cpfpInfo); + return; } else { res.json({ ancestors: [] }); return; } - if (cpfpInfo) { - res.json(cpfpInfo); - return; - } } - res.status(404).send(`Transaction has no CPFP info available.`); } private getBackendInfo(req: Request, res: Response) { @@ -652,7 +651,7 @@ class BitcoinRoutes { if (result) { res.json(result); } else { - res.status(404).send('not found'); + res.status(204).send(); } } catch (e) { res.status(500).send(e instanceof Error ? e.message : e); diff --git a/backend/src/api/mining/mining-routes.ts b/backend/src/api/mining/mining-routes.ts index f7f392068..0198f9ab4 100644 --- a/backend/src/api/mining/mining-routes.ts +++ b/backend/src/api/mining/mining-routes.ts @@ -263,7 +263,7 @@ class MiningRoutes { const audit = await BlocksAuditsRepository.$getBlockAudit(req.params.hash); if (!audit) { - res.status(404).send(`This block has not been audited.`); + res.status(204).send(`This block has not been audited.`); return; } diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 455c74c99..0cd4a86c2 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -210,6 +210,7 @@
- +

Details

diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index 4fedc3912..d41ba4b63 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -57,6 +57,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { fetchCpfp$ = new Subject(); fetchRbfHistory$ = new Subject(); fetchCachedTx$ = new Subject(); + isCached: boolean = false; now = new Date().getTime(); timeAvg$: Observable; liquidUnblinding = new LiquidUnblinding(); @@ -196,6 +197,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { } this.tx = tx; + this.isCached = true; if (tx.fee === undefined) { this.tx.fee = 0; } @@ -289,6 +291,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { } this.tx = tx; + this.isCached = false; if (tx.fee === undefined) { this.tx.fee = 0; } diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.ts b/frontend/src/app/components/transactions-list/transactions-list.component.ts index c720d5960..afda646d7 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.ts +++ b/frontend/src/app/components/transactions-list/transactions-list.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, Input, ChangeDetectionStrategy, OnChanges, Output, EventEmitter, ChangeDetectorRef } from '@angular/core'; import { StateService } from '../../services/state.service'; import { CacheService } from '../../services/cache.service'; -import { Observable, ReplaySubject, BehaviorSubject, merge, Subscription } from 'rxjs'; +import { Observable, ReplaySubject, BehaviorSubject, merge, Subscription, of } from 'rxjs'; import { Outspend, Transaction, Vin, Vout } from '../../interfaces/electrs.interface'; import { ElectrsApiService } from '../../services/electrs-api.service'; import { environment } from '../../../environments/environment'; @@ -23,6 +23,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { showMoreIncrement = 1000; @Input() transactions: Transaction[]; + @Input() cached: boolean = false; @Input() showConfirmations = false; @Input() transactionPage = false; @Input() errorUnblinded = false; @@ -67,7 +68,13 @@ export class TransactionsListComponent implements OnInit, OnChanges { this.outspendsSubscription = merge( this.refreshOutspends$ .pipe( - switchMap((txIds) => this.apiService.getOutspendsBatched$(txIds)), + switchMap((txIds) => { + if (!this.cached) { + return this.apiService.getOutspendsBatched$(txIds); + } else { + return of([]); + } + }), tap((outspends: Outspend[][]) => { if (!this.transactions) { return; @@ -155,7 +162,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { ).subscribe(); }); const txIds = this.transactions.filter((tx) => !tx._outspends).map((tx) => tx.txid); - if (txIds.length) { + if (txIds.length && !this.cached) { this.refreshOutspends$.next(txIds); } if (this.stateService.env.LIGHTNING) { diff --git a/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts b/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts index 6be475243..1c5ee5391 100644 --- a/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts +++ b/frontend/src/app/components/tx-bowtie-graph/tx-bowtie-graph.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Input, OnChanges, HostListener, Inject, LOCALE_ID } import { StateService } from '../../services/state.service'; import { Outspend, Transaction } from '../../interfaces/electrs.interface'; import { Router } from '@angular/router'; -import { ReplaySubject, merge, Subscription } from 'rxjs'; +import { ReplaySubject, merge, Subscription, of } from 'rxjs'; import { tap, switchMap } from 'rxjs/operators'; import { ApiService } from '../../services/api.service'; import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe'; @@ -40,6 +40,7 @@ interface Xput { export class TxBowtieGraphComponent implements OnInit, OnChanges { @Input() tx: Transaction; @Input() network: string; + @Input() cached: boolean = false; @Input() width = 1200; @Input() height = 600; @Input() lineLimit = 250; @@ -107,7 +108,13 @@ export class TxBowtieGraphComponent implements OnInit, OnChanges { this.outspendsSubscription = merge( this.refreshOutspends$ .pipe( - switchMap((txid) => this.apiService.getOutspendsBatched$([txid])), + switchMap((txid) => { + if (!this.cached) { + return this.apiService.getOutspendsBatched$([txid]); + } else { + return of(null); + } + }), tap((outspends: Outspend[][]) => { if (!this.tx || !outspends || !outspends.length) { return; @@ -132,7 +139,9 @@ export class TxBowtieGraphComponent implements OnInit, OnChanges { ngOnChanges(): void { this.initGraph(); - this.refreshOutspends$.next(this.tx.txid); + if (!this.cached) { + this.refreshOutspends$.next(this.tx.txid); + } } initGraph(): void {