Merge pull request #5573 from mempool/mononaut/fix-partial-utxo-chart
never show a utxo chart with missing data
This commit is contained in:
commit
ddf1a300b6
@ -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,27 +350,29 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update utxos in-place
|
// update utxos in-place
|
||||||
let utxosChanged = false;
|
if (this.utxos != null) {
|
||||||
for (const vin of transaction.vin) {
|
let utxosChanged = false;
|
||||||
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === vin.txid && utxo.vout === vin.vout);
|
for (const vin of transaction.vin) {
|
||||||
if (utxoIndex !== -1) {
|
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === vin.txid && utxo.vout === vin.vout);
|
||||||
this.utxos.splice(utxoIndex, 1);
|
if (utxoIndex !== -1) {
|
||||||
utxosChanged = true;
|
this.utxos.splice(utxoIndex, 1);
|
||||||
|
utxosChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
for (const [index, vout] of transaction.vout.entries()) {
|
||||||
for (const [index, vout] of transaction.vout.entries()) {
|
if (vout.scriptpubkey_address === this.address.address) {
|
||||||
if (vout.scriptpubkey_address === this.address.address) {
|
this.utxos.push({
|
||||||
this.utxos.push({
|
txid: transaction.txid,
|
||||||
txid: transaction.txid,
|
vout: index,
|
||||||
vout: index,
|
value: vout.value,
|
||||||
value: vout.value,
|
status: JSON.parse(JSON.stringify(transaction.status)),
|
||||||
status: JSON.parse(JSON.stringify(transaction.status)),
|
});
|
||||||
});
|
utxosChanged = true;
|
||||||
utxosChanged = true;
|
}
|
||||||
|
}
|
||||||
|
if (utxosChanged) {
|
||||||
|
this.utxos = this.utxos.slice();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (utxosChanged) {
|
|
||||||
this.utxos = this.utxos.slice();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -385,29 +387,31 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
this.transactions = this.transactions.slice();
|
this.transactions = this.transactions.slice();
|
||||||
|
|
||||||
// update utxos in-place
|
// update utxos in-place
|
||||||
let utxosChanged = false;
|
if (this.utxos != null) {
|
||||||
for (const vin of transaction.vin) {
|
let utxosChanged = false;
|
||||||
if (vin.prevout?.scriptpubkey_address === this.address.address) {
|
for (const vin of transaction.vin) {
|
||||||
this.utxos.push({
|
if (vin.prevout?.scriptpubkey_address === this.address.address) {
|
||||||
txid: vin.txid,
|
this.utxos.push({
|
||||||
vout: vin.vout,
|
txid: vin.txid,
|
||||||
value: vin.prevout.value,
|
vout: vin.vout,
|
||||||
status: { confirmed: true }, // Assuming the input was confirmed
|
value: vin.prevout.value,
|
||||||
});
|
status: { confirmed: true }, // Assuming the input was confirmed
|
||||||
utxosChanged = true;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const [index, vout] of transaction.vout.entries()) {
|
|
||||||
if (vout.scriptpubkey_address === this.address.address) {
|
|
||||||
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === transaction.txid && utxo.vout === index);
|
|
||||||
if (utxoIndex !== -1) {
|
|
||||||
this.utxos.splice(utxoIndex, 1);
|
|
||||||
utxosChanged = true;
|
utxosChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for (const [index, vout] of transaction.vout.entries()) {
|
||||||
if (utxosChanged) {
|
if (vout.scriptpubkey_address === this.address.address) {
|
||||||
this.utxos = this.utxos.slice();
|
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === transaction.txid && utxo.vout === index);
|
||||||
|
if (utxoIndex !== -1) {
|
||||||
|
this.utxos.splice(utxoIndex, 1);
|
||||||
|
utxosChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (utxosChanged) {
|
||||||
|
this.utxos = this.utxos.slice();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -415,27 +419,29 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
confirmTransaction(transaction: Transaction): void {
|
confirmTransaction(transaction: Transaction): void {
|
||||||
// update utxos in-place
|
// update utxos in-place
|
||||||
let utxosChanged = false;
|
if (this.utxos != null) {
|
||||||
for (const vin of transaction.vin) {
|
let utxosChanged = false;
|
||||||
if (vin.prevout?.scriptpubkey_address === this.address.address) {
|
for (const vin of transaction.vin) {
|
||||||
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === vin.txid && utxo.vout === vin.vout);
|
if (vin.prevout?.scriptpubkey_address === this.address.address) {
|
||||||
if (utxoIndex !== -1) {
|
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === vin.txid && utxo.vout === vin.vout);
|
||||||
this.utxos[utxoIndex].status = JSON.parse(JSON.stringify(transaction.status));
|
if (utxoIndex !== -1) {
|
||||||
utxosChanged = true;
|
this.utxos[utxoIndex].status = JSON.parse(JSON.stringify(transaction.status));
|
||||||
|
utxosChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
for (const [index, vout] of transaction.vout.entries()) {
|
||||||
for (const [index, vout] of transaction.vout.entries()) {
|
if (vout.scriptpubkey_address === this.address.address) {
|
||||||
if (vout.scriptpubkey_address === this.address.address) {
|
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === transaction.txid && utxo.vout === index);
|
||||||
const utxoIndex = this.utxos.findIndex((utxo) => utxo.txid === transaction.txid && utxo.vout === index);
|
if (utxoIndex !== -1) {
|
||||||
if (utxoIndex !== -1) {
|
this.utxos[utxoIndex].status = JSON.parse(JSON.stringify(transaction.status));
|
||||||
this.utxos[utxoIndex].status = JSON.parse(JSON.stringify(transaction.status));
|
utxosChanged = true;
|
||||||
utxosChanged = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (utxosChanged) {
|
||||||
if (utxosChanged) {
|
this.utxos = this.utxos.slice();
|
||||||
this.utxos = this.utxos.slice();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user