Improve taproot detection. Only display when detected.

This commit is contained in:
softsimon 2021-05-01 21:03:01 +04:00
parent 0b4da88802
commit 72d01a0b67
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
2 changed files with 10 additions and 2 deletions

View File

@ -90,7 +90,7 @@
<tbody>
<tr>
<td class="td-width" i18n="transaction.version">Version</td>
<td>{{ block.version | decimal2hex }} <span *ngIf="block.height > 681407" class="badge ml-1" [ngClass]="{'badge-success': hasTaproot(block.version), 'badge-danger': !hasTaproot(block.version) }">Taproot</span></td>
<td>{{ block.version | decimal2hex }} <span *ngIf="displayTaprootStatus() && hasTaproot(block.version)" class="badge badge-success ml-1" >Taproot</span></td>
</tr>
<tr>
<td i18n="block.merkle-root">Merkle root</td>

View File

@ -204,6 +204,14 @@ export class BlockComponent implements OnInit, OnDestroy {
}
hasTaproot(version: number): boolean {
return (Number(version) & (1 << 2)) > 0;
const versionBit = 2; // Taproot
return (Number(version) & (1 << versionBit)) === (1 << versionBit);
}
displayTaprootStatus(): boolean {
if (this.stateService.network !== '') {
return false;
}
return this.block && this.block.height > 681407 && (new Date().getTime() / 1000) < 1628640000;
}
}