parent
1feb985bec
commit
0753b11840
@ -76,7 +76,7 @@ export interface Vout {
|
|||||||
scriptpubkey: string;
|
scriptpubkey: string;
|
||||||
scriptpubkey_asm: string;
|
scriptpubkey_asm: string;
|
||||||
scriptpubkey_type: string;
|
scriptpubkey_type: string;
|
||||||
scriptpubkey_address: string;
|
scriptpubkey_address?: string;
|
||||||
value: number;
|
value: number;
|
||||||
|
|
||||||
asset?: string;
|
asset?: string;
|
||||||
|
1
frontend/.gitignore
vendored
1
frontend/.gitignore
vendored
@ -47,3 +47,4 @@ Thumbs.db
|
|||||||
|
|
||||||
src/resources/assets.json
|
src/resources/assets.json
|
||||||
src/resources/assets.minimal.json
|
src/resources/assets.minimal.json
|
||||||
|
src/resources/pools.json
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"start": "npm run sync-assets-dev && ng serve --proxy-config proxy.conf.json",
|
"start": "npm run sync-assets-dev && ng serve --proxy-config proxy.conf.json",
|
||||||
"build": "ng build --prod && npm run sync-assets",
|
"build": "ng build --prod && npm run sync-assets",
|
||||||
"sync-assets": "node sync-asset-registry.js",
|
"sync-assets": "node sync-assets.js",
|
||||||
"sync-assets-dev": "node sync-asset-registry.js dev",
|
"sync-assets-dev": "node sync-assets.js dev",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e"
|
"e2e": "ng e2e"
|
||||||
|
@ -49,6 +49,7 @@ import { AssetComponent } from './components/asset/asset.component';
|
|||||||
import { ScriptpubkeyTypePipe } from './pipes/scriptpubkey-type-pipe/scriptpubkey-type.pipe';
|
import { ScriptpubkeyTypePipe } from './pipes/scriptpubkey-type-pipe/scriptpubkey-type.pipe';
|
||||||
import { AssetsComponent } from './assets/assets.component';
|
import { AssetsComponent } from './assets/assets.component';
|
||||||
import { RelativeUrlPipe } from './pipes/relative-url/relative-url.pipe';
|
import { RelativeUrlPipe } from './pipes/relative-url/relative-url.pipe';
|
||||||
|
import { MinerComponent } from './pipes/miner/miner.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -88,6 +89,7 @@ import { RelativeUrlPipe } from './pipes/relative-url/relative-url.pipe';
|
|||||||
ScriptpubkeyTypePipe,
|
ScriptpubkeyTypePipe,
|
||||||
AssetsComponent,
|
AssetsComponent,
|
||||||
RelativeUrlPipe,
|
RelativeUrlPipe,
|
||||||
|
MinerComponent,
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
@ -49,12 +49,12 @@
|
|||||||
<ng-template [ngIf]="fees !== undefined" [ngIfElse]="loadingFees">
|
<ng-template [ngIf]="fees !== undefined" [ngIfElse]="loadingFees">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Total fees</td>
|
<td>Total fees</td>
|
||||||
<td><app-amount [satoshis]="fees * 100000000" digitsInfo="1.2-8"></app-amount> (<app-fiat [value]="fees * 100000000" digitsInfo="1.0-0"></app-fiat>)</td>
|
<td><app-amount [satoshis]="fees * 100000000" digitsInfo="1.2-2"></app-amount> (<app-fiat [value]="fees * 100000000" digitsInfo="1.0-0"></app-fiat>)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Reward + fees:</td>
|
<td>Reward + fees:</td>
|
||||||
<td>
|
<td>
|
||||||
<app-amount [satoshis]="(blockSubsidy + fees) * 100000000" digitsInfo="1.2-8"></app-amount> (<app-fiat [value]="(blockSubsidy + fees) * 100000000" digitsInfo="1.0-0"></app-fiat>)
|
<app-amount [satoshis]="(blockSubsidy + fees) * 100000000" digitsInfo="1.2-2"></app-amount> (<app-fiat [value]="(blockSubsidy + fees) * 100000000" digitsInfo="1.0-0"></app-fiat>)
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
@ -68,6 +68,10 @@
|
|||||||
<td><span class="skeleton-loader"></span></td>
|
<td><span class="skeleton-loader"></span></td>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
<tr>
|
||||||
|
<td>Miner</td>
|
||||||
|
<td><app-miner [coinbaseTransaction]="transactions && transactions[0]"></app-miner></td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,6 +37,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(
|
.pipe(
|
||||||
switchMap((params: ParamMap) => {
|
switchMap((params: ParamMap) => {
|
||||||
const blockHash: string = params.get('id') || '';
|
const blockHash: string = params.get('id') || '';
|
||||||
|
this.block = undefined;
|
||||||
this.error = undefined;
|
this.error = undefined;
|
||||||
this.fees = undefined;
|
this.fees = undefined;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
left: -12px;
|
left: -12px;
|
||||||
text-shadow: 0px 32px 3px #111;
|
text-shadow: 0px 32px 3px #111;
|
||||||
z-index: 100;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bitcoin-block::after {
|
.bitcoin-block::after {
|
||||||
|
12
frontend/src/app/pipes/miner/miner.component.html
Normal file
12
frontend/src/app/pipes/miner/miner.component.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<ng-template [ngIf]="loading" [ngIfElse]="done">
|
||||||
|
<span class="skeleton-loader"></span>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<ng-template #done>
|
||||||
|
<ng-template [ngIf]="miner" [ngIfElse]="unknownMiner">
|
||||||
|
<a [title]="title" [href]="url" target="_blank" class="badge badge-primary">{{ miner }}</a>
|
||||||
|
</ng-template>
|
||||||
|
<ng-template #unknownMiner>
|
||||||
|
<span class="badge badge-secondary">Unknown</span>
|
||||||
|
</ng-template>
|
||||||
|
</ng-template>
|
3
frontend/src/app/pipes/miner/miner.component.scss
Normal file
3
frontend/src/app/pipes/miner/miner.component.scss
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.badge {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
68
frontend/src/app/pipes/miner/miner.component.ts
Normal file
68
frontend/src/app/pipes/miner/miner.component.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import { Component, Input, OnChanges } from '@angular/core';
|
||||||
|
import { AssetsService } from 'src/app/services/assets.service';
|
||||||
|
import { Transaction } from 'src/app/interfaces/electrs.interface';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-miner',
|
||||||
|
templateUrl: './miner.component.html',
|
||||||
|
styleUrls: ['./miner.component.scss'],
|
||||||
|
})
|
||||||
|
export class MinerComponent implements OnChanges {
|
||||||
|
@Input() coinbaseTransaction: Transaction;
|
||||||
|
miner = '';
|
||||||
|
title = '';
|
||||||
|
url = '';
|
||||||
|
loading = true;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private assetsService: AssetsService,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
ngOnChanges() {
|
||||||
|
this.loading = true;
|
||||||
|
this.findMinerFromCoinbase();
|
||||||
|
}
|
||||||
|
|
||||||
|
findMinerFromCoinbase() {
|
||||||
|
if (this.coinbaseTransaction == null || this.coinbaseTransaction.vin == null || this.coinbaseTransaction.vin.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.assetsService.getMiningPools$.subscribe((pools) => {
|
||||||
|
for (const vout of this.coinbaseTransaction.vout) {
|
||||||
|
if (!vout.scriptpubkey_address) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pools.payout_addresses[vout.scriptpubkey_address]) {
|
||||||
|
this.miner = pools.payout_addresses[vout.scriptpubkey_address].name;
|
||||||
|
this.title = 'Identified by payout address: ' + vout.scriptpubkey_address;
|
||||||
|
this.url = pools.payout_addresses[vout.scriptpubkey_address].link;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const tag in pools.coinbase_tags) {
|
||||||
|
if (pools.coinbase_tags.hasOwnProperty(tag)) {
|
||||||
|
const coinbaseAscii = this.hex2ascii(this.coinbaseTransaction.vin[0].scriptsig);
|
||||||
|
if (coinbaseAscii.indexOf(tag) > -1) {
|
||||||
|
this.miner = pools.coinbase_tags[tag].name;
|
||||||
|
this.title = 'Identified by coinbase tag: ' + tag;
|
||||||
|
this.url = pools.coinbase_tags[tag].link;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hex2ascii(hex: string) {
|
||||||
|
let str = '';
|
||||||
|
for (let i = 0; i < hex.length; i += 2) {
|
||||||
|
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
@ -9,11 +9,13 @@ import { shareReplay } from 'rxjs/operators';
|
|||||||
export class AssetsService {
|
export class AssetsService {
|
||||||
getAssetsJson$: Observable<any>;
|
getAssetsJson$: Observable<any>;
|
||||||
getAssetsMinimalJson$: Observable<any>;
|
getAssetsMinimalJson$: Observable<any>;
|
||||||
|
getMiningPools$: Observable<any>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
) {
|
) {
|
||||||
this.getAssetsJson$ = this.httpClient.get('/resources/assets.json').pipe(shareReplay());
|
this.getAssetsJson$ = this.httpClient.get('/resources/assets.json').pipe(shareReplay());
|
||||||
this.getAssetsMinimalJson$ = this.httpClient.get('/resources/assets.minimal.json').pipe(shareReplay());
|
this.getAssetsMinimalJson$ = this.httpClient.get('/resources/assets.minimal.json').pipe(shareReplay());
|
||||||
|
this.getMiningPools$ = this.httpClient.get('/resources/pools.json').pipe(shareReplay());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,3 +17,5 @@ console.log('Downloading assets');
|
|||||||
download(PATH + 'assets.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.json');
|
download(PATH + 'assets.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.json');
|
||||||
console.log('Downloading assets minimal');
|
console.log('Downloading assets minimal');
|
||||||
download(PATH + 'assets.minimal.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.minimal.json');
|
download(PATH + 'assets.minimal.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.minimal.json');
|
||||||
|
console.log('Downloading mining pools info');
|
||||||
|
download(PATH + 'pools.json', 'https://raw.githubusercontent.com/btccom/Blockchain-Known-Pools/master/pools.json');
|
Loading…
x
Reference in New Issue
Block a user