Fix load more inputs for non-esplora backends

This commit is contained in:
Mononaut 2022-11-22 14:48:34 +09:00
parent d107286344
commit 6cd1f9e870
No known key found for this signature in database
GPG key ID: A3F058E41374C04E
2 changed files with 21 additions and 11 deletions

View file

@ -283,7 +283,7 @@
<div class="float-left mt-2-5" *ngIf="!transactionPage && !tx.vin[0].is_coinbase && tx.fee !== -1">
{{ tx.fee / (tx.weight / 4) | feeRounding }} <span class="symbol" i18n="shared.sat-vbyte|sat/vB">sat/vB</span> <span class="d-none d-sm-inline-block">&nbsp;&ndash; {{ tx.fee | number }} <span class="symbol" i18n="shared.sat|sat">sat</span> <span class="fiat"><app-fiat [value]="tx.fee"></app-fiat></span></span>
</div>
<div class="float-left mt-2-5 grey-info-text" *ngIf="tx.fee === -1" i18n="transactions-list.load-to-reveal-fee-info">Show all inputs to reveal fee data</div>
<div class="float-left mt-2-5 grey-info-text" *ngIf="tx.fee === -1" i18n="transactions-list.load-to-reveal-fee-info">Show more inputs to reveal fee data</div>
<div class="float-right">
<ng-container *ngIf="showConfirmations && latestBlock$ | async as latestBlock">

View file

@ -209,17 +209,19 @@ export class TransactionsListComponent implements OnInit, OnChanges {
}
loadMoreInputs(tx: Transaction): void {
tx['@vinLimit'] = false;
this.electrsApiService.getTransaction$(tx.txid)
.subscribe((newTx) => {
tx.vin = newTx.vin;
tx.fee = newTx.fee;
this.ref.markForCheck();
});
if (!tx['@vinLoaded']) {
this.electrsApiService.getTransaction$(tx.txid)
.subscribe((newTx) => {
tx['@vinLoaded'] = true;
tx.vin = newTx.vin;
tx.fee = newTx.fee;
this.ref.markForCheck();
});
}
}
showMoreInputs(tx: Transaction): void {
this.loadMoreInputs(tx);
tx['@vinLimit'] = this.getVinLimit(tx, true);
}
@ -228,11 +230,19 @@ export class TransactionsListComponent implements OnInit, OnChanges {
}
getVinLimit(tx: Transaction, next = false): number {
return Math.min(Math.max(tx['@vinLimit'] || 0, this.inputRowLimit) + (next ? this.showMoreIncrement : 0), tx.vin.length);
if ((tx['@vinLimit'] || 0) > this.inputRowLimit) {
return Math.min(tx['@vinLimit'] + (next ? this.showMoreIncrement : 0), tx.vin.length);
} else {
return Math.min((next ? this.showMoreIncrement : this.inputRowLimit), tx.vin.length);
}
}
getVoutLimit(tx: Transaction, next = false): number {
return Math.min(Math.max(tx['@voutLimit'] || 0, this.outputRowLimit) + (next ? this.showMoreIncrement : 0), tx.vout.length);
if ((tx['@voutLimit'] || 0) > this.outputRowLimit) {
return Math.min(tx['@voutLimit'] + (next ? this.showMoreIncrement : 0), tx.vout.length);
} else {
return Math.min((next ? this.showMoreIncrement : this.outputRowLimit), tx.vout.length);
}
}
ngOnDestroy(): void {