Display more accurate price on prevout/spent outputs in bowtie tooltip

This commit is contained in:
natsoni
2024-03-17 16:25:36 +09:00
parent df107d34b4
commit 2dc6f6ff5a
6 changed files with 157 additions and 12 deletions

View File

@@ -44,6 +44,28 @@
<span *ngSwitchCase="'fee'" i18n="transaction.fee|Transaction fee">Fee</span>
</ng-container>
<span *ngIf="line.type !== 'fee'"> #{{ line.index + 1 }}</span>
<ng-container [ngSwitch]="line.type">
<span *ngSwitchCase="'input'">
<ng-container *ngIf="line.status?.block_height">
<ng-container *ngIf="line.blockHeight; else noBlockHeight">
<ng-container *ngTemplateOutlet="nBlocksAgo; context:{n: line.blockHeight - line?.status?.block_height, connector: false}"></ng-container>
</ng-container>
<ng-template #noBlockHeight>
<ng-container *ngTemplateOutlet="nBlocksAgo; context:{n: chainTip + 1 - line?.status?.block_height, connector: false}"></ng-container>
</ng-template>
</ng-container>
</span>
<span *ngSwitchCase="'output'">
<ng-container *ngIf="line.blockHeight && line?.spent">
<ng-container *ngIf="line?.status?.block_height; else noBlockHeight">
<ng-container *ngTemplateOutlet="nBlocksLater; context:{n: line?.status?.block_height - line.blockHeight, connector: false}"></ng-container>
</ng-container>
<ng-template #noBlockHeight>
<ng-container *ngTemplateOutlet="nBlocksLater; context:{n: chainTip + 1 - line.blockHeight, connector: false}"></ng-container>
</ng-template>
</ng-container>
</span>
</ng-container>
</p>
<ng-container *ngIf="isConnector && line.txid">
<p>
@@ -51,8 +73,26 @@
<app-truncate [text]="line.txid"></app-truncate>
</p>
<ng-container [ngSwitch]="line.type">
<p *ngSwitchCase="'input'"><span i18n="transaction.output">Output</span>&nbsp; #{{ line.vout + 1 }}</p>
<p *ngSwitchCase="'output'"><span i18n="transaction.input">Input</span>&nbsp; #{{ line.vin + 1 }}</p>
<p *ngSwitchCase="'input'"><span i18n="transaction.output">Output</span>&nbsp; #{{ line.vout + 1 }}
<ng-container *ngIf="line.status?.block_height">
<ng-container *ngIf="line.blockHeight; else noBlockHeight">
<ng-container *ngTemplateOutlet="nBlocksAgo; context:{n: line.blockHeight - line?.status?.block_height, connector: true}"></ng-container>
</ng-container>
<ng-template #noBlockHeight>
<ng-container *ngTemplateOutlet="nBlocksAgo; context:{n: chainTip + 1 - line?.status?.block_height, connector: true}"></ng-container>
</ng-template>
</ng-container>
</p>
<p *ngSwitchCase="'output'"><span i18n="transaction.input">Input</span>&nbsp; #{{ line.vin + 1 }}
<ng-container *ngIf="line.blockHeight">
<ng-container *ngIf="line?.status?.block_height; else noBlockHeight">
<ng-container *ngTemplateOutlet="nBlocksLater; context:{n: line?.status?.block_height - line.blockHeight, connector: true}"></ng-container>
</ng-container>
<ng-template #noBlockHeight>
<ng-container *ngTemplateOutlet="nBlocksLater; context:{n: chainTip + 1 - line.blockHeight, connector: true}"></ng-container>
</ng-template>
</ng-container>
</p>
</ng-container>
</ng-container>
<p *ngIf="line.displayValue == null && line.confidential" i18n="shared.confidential">Confidential</p>
@@ -66,7 +106,7 @@
</ng-template>
</ng-template>
<ng-template #defaultOutput>
<app-amount [blockConversion]="blockConversion" [satoshis]="line.displayValue"></app-amount>
<app-amount [blockConversion]="isConnector ? blockConversions[line?.status?.block_time] : blockConversions[line?.timestamp]" [satoshis]="line.displayValue" [forceBlockConversion]="isConnector && line?.status?.block_time"></app-amount>
</ng-template>
</p>
<p *ngIf="line.type !== 'fee' && line.address" class="address">
@@ -77,4 +117,42 @@
<ng-template #assetBox let-item>
{{ item.displayValue / pow(10, assetsMinimal[item.asset][3]) | number: '1.' + assetsMinimal[item.asset][3] + '-' + assetsMinimal[item.asset][3] }} <span class="symbol">{{ assetsMinimal[item.asset][1] }}</span>
</ng-template>
<ng-template #oneBlockAgo>
<span i18n="shared.one-block-ago">1 block ago</span>
</ng-template>
<ng-template #oneBlockLater>
<span i18n="shared.one-block-later">1 block later</span>
</ng-template>
<ng-template #inTheSameBlock>
<span i18n="shared.in-the-same-block">in the same block</span>
</ng-template>
<ng-template #nBlocksAgo let-n="n" let-connector="connector">
(<span *ngIf="!connector">prevout </span>
<ng-container *ngIf="n > 1">
<span>{{ n }} <ng-container i18n="shared.n-blocks-ago">blocks ago</ng-container>)</span>
</ng-container>
<ng-container *ngIf="n === 1">
<span><ng-container *ngTemplateOutlet="oneBlockAgo"></ng-container>)</span>
</ng-container>
<ng-container *ngIf="n === 0">
<span><ng-container *ngTemplateOutlet="inTheSameBlock"></ng-container>)</span>
</ng-container>
</ng-template>
<ng-template #nBlocksLater let-n="n" let-connector="connector">
(<span *ngIf="!connector" i18n="shared.spent">spent </span>
<ng-container *ngIf="n > 1">
<span>{{ n }} <ng-container i18n="shared.n-blocks-later">blocks later</ng-container>)</span>
</ng-container>
<ng-container *ngIf="n === 1">
<span><ng-container *ngTemplateOutlet="oneBlockLater"></ng-container>)</span>
</ng-container>
<ng-container *ngIf="n === 0">
<span><ng-container *ngTemplateOutlet="inTheSameBlock"></ng-container>)</span>
</ng-container>
</ng-template>