Merge pull request #5573 from mempool/mononaut/fix-partial-utxo-chart

never show a utxo chart with missing data
This commit is contained in:
softsimon 2024-10-07 15:16:25 +09:00 committed by GitHub
commit ddf1a300b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -219,11 +219,11 @@ export class AddressComponent implements OnInit, OnDestroy {
address.is_pubkey address.is_pubkey
? this.electrsApiService.getScriptHashTransactions$((address.address.length === 66 ? '21' : '41') + address.address + 'ac') ? this.electrsApiService.getScriptHashTransactions$((address.address.length === 66 ? '21' : '41') + address.address + 'ac')
: this.electrsApiService.getAddressTransactions$(address.address), : this.electrsApiService.getAddressTransactions$(address.address),
(utxoCount >= 2 && utxoCount <= 500 ? (address.is_pubkey (utxoCount > 2 && utxoCount <= 500 ? (address.is_pubkey
? this.electrsApiService.getScriptHashUtxos$((address.address.length === 66 ? '21' : '41') + address.address + 'ac') ? this.electrsApiService.getScriptHashUtxos$((address.address.length === 66 ? '21' : '41') + address.address + 'ac')
: this.electrsApiService.getAddressUtxos$(address.address)) : of([])).pipe( : this.electrsApiService.getAddressUtxos$(address.address)) : of(null)).pipe(
catchError(() => { catchError(() => {
return of([]); return of(null);
}) })
) )
]); ]);
@ -350,6 +350,7 @@ export class AddressComponent implements OnInit, OnDestroy {
} }
// update utxos in-place // update utxos in-place
if (this.utxos != null) {
let utxosChanged = false; let utxosChanged = false;
for (const vin of transaction.vin) { for (const vin of transaction.vin) {
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === vin.txid && utxo.vout === vin.vout); const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === vin.txid && utxo.vout === vin.vout);
@ -372,6 +373,7 @@ export class AddressComponent implements OnInit, OnDestroy {
if (utxosChanged) { if (utxosChanged) {
this.utxos = this.utxos.slice(); this.utxos = this.utxos.slice();
} }
}
return true; return true;
} }
@ -385,6 +387,7 @@ export class AddressComponent implements OnInit, OnDestroy {
this.transactions = this.transactions.slice(); this.transactions = this.transactions.slice();
// update utxos in-place // update utxos in-place
if (this.utxos != null) {
let utxosChanged = false; let utxosChanged = false;
for (const vin of transaction.vin) { for (const vin of transaction.vin) {
if (vin.prevout?.scriptpubkey_address === this.address.address) { if (vin.prevout?.scriptpubkey_address === this.address.address) {
@ -409,12 +412,14 @@ export class AddressComponent implements OnInit, OnDestroy {
if (utxosChanged) { if (utxosChanged) {
this.utxos = this.utxos.slice(); this.utxos = this.utxos.slice();
} }
}
return true; return true;
} }
confirmTransaction(transaction: Transaction): void { confirmTransaction(transaction: Transaction): void {
// update utxos in-place // update utxos in-place
if (this.utxos != null) {
let utxosChanged = false; let utxosChanged = false;
for (const vin of transaction.vin) { for (const vin of transaction.vin) {
if (vin.prevout?.scriptpubkey_address === this.address.address) { if (vin.prevout?.scriptpubkey_address === this.address.address) {
@ -438,6 +443,7 @@ export class AddressComponent implements OnInit, OnDestroy {
this.utxos = this.utxos.slice(); this.utxos = this.utxos.slice();
} }
} }
}
loadMore(): void { loadMore(): void {
if (this.isLoadingTransactions || this.fullyLoaded) { if (this.isLoadingTransactions || this.fullyLoaded) {