Merge branch 'master' into simon/angular-universal

* master:
  correcting merge
  Remove extra space in price server URL
  Modify upgrade script to append repo before tag name
  Merge "getInitData" method from simon/angular-universal.
  Replace opennode usd price source with wiz api. fixes #166
  Display confidential instead of nothing for confidential assets. fixes #110
  Detect confidential assets and display properly. fixes #109
  Allow searching for and viewing assets not in the asset registry. fixes #111

# Conflicts:
#	backend/src/api/websocket-handler.ts
This commit is contained in:
softsimon 2020-11-23 14:08:50 +07:00
commit aaf9d9be9f
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
9 changed files with 63 additions and 37 deletions

View File

@ -2,10 +2,8 @@ import logger from '../logger';
import axios from 'axios'; import axios from 'axios';
class FiatConversion { class FiatConversion {
private tickers = { private conversionRates = {
'BTCUSD': { 'USD': 0
'USD': 4110.78
},
}; };
constructor() { } constructor() { }
@ -16,16 +14,19 @@ class FiatConversion {
this.updateCurrency(); this.updateCurrency();
} }
public getTickers() { public getConversionRates() {
return this.tickers; return this.conversionRates;
} }
private async updateCurrency(): Promise<void> { private async updateCurrency(): Promise<void> {
try { try {
const response = await axios.get('https://api.opennode.co/v1/rates'); const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices');
this.tickers = response.data.data; const usd = response.data.data.find((item: any) => item.currencyCode === 'USD');
this.conversionRates = {
'USD': usd.price,
};
} catch (e) { } catch (e) {
logger.err('Error updating currency from OpenNode: ' + e); logger.err('Error updating fiat conversion rates: ' + e);
} }
} }
} }

View File

@ -126,7 +126,7 @@ class WebsocketHandler {
'vBytesPerSecond': memPool.getVBytesPerSecond(), 'vBytesPerSecond': memPool.getVBytesPerSecond(),
'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(), 'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(),
'blocks': _blocks, 'blocks': _blocks,
'conversions': fiatConversion.getTickers()['BTCUSD'], 'conversions': fiatConversion.getConversionRates(),
'mempool-blocks': mempoolBlocks.getMempoolBlocks(), 'mempool-blocks': mempoolBlocks.getMempoolBlocks(),
'transactions': memPool.getLatestTransactions(), 'transactions': memPool.getLatestTransactions(),
'git-commit': backendInfo.gitCommitHash, 'git-commit': backendInfo.gitCommitHash,

View File

@ -18,15 +18,15 @@
<tbody> <tbody>
<tr> <tr>
<td>Total received</td> <td>Total received</td>
<td><app-amount [satoshis]="receieved" [noFiat]="true"></app-amount></td> <td *ngIf="address.chain_stats.funded_txo_sum !== undefined; else confidentialTd"><app-amount [satoshis]="receieved" [noFiat]="true"></app-amount></td>
</tr> </tr>
<tr> <tr>
<td>Total sent</td> <td>Total sent</td>
<td><app-amount [satoshis]="sent" [noFiat]="true"></app-amount></td> <td *ngIf="address.chain_stats.spent_txo_sum !== undefined; else confidentialTd"><app-amount [satoshis]="sent" [noFiat]="true"></app-amount></td>
</tr> </tr>
<tr> <tr>
<td>Balance</td> <td>Balance</td>
<td><app-amount [satoshis]="receieved - sent" [noFiat]="true"></app-amount> (<app-fiat [value]="receieved - sent"></app-fiat>)</td> <td *ngIf="address.chain_stats.funded_txo_sum !== undefined; else confidentialTd"><app-amount [satoshis]="receieved - sent" [noFiat]="true"></app-amount> (<app-fiat [value]="receieved - sent"></app-fiat>)</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -106,4 +106,8 @@
</div> </div>
<br> <br>
<ng-template #confidentialTd>
<td>Confidential</td>
</ng-template>

View File

@ -24,7 +24,7 @@
<td>Precision</td> <td>Precision</td>
<td>{{ assetContract[3] }}</td> <td>{{ assetContract[3] }}</td>
</tr> </tr>
<tr *ngIf="!isNativeAsset"> <tr *ngIf="!isNativeAsset && assetContract[0]">
<td>Issuer</td> <td>Issuer</td>
<td><a target="_blank" href="{{ 'http://' + assetContract[0] }}">{{ assetContract[0] }}</a></td> <td><a target="_blank" href="{{ 'http://' + assetContract[0] }}">{{ assetContract[0] }}</a></td>
</tr> </tr>
@ -49,15 +49,15 @@
</tr> </tr>
<tr *ngIf="!isNativeAsset"> <tr *ngIf="!isNativeAsset">
<td>Issued amount</td> <td>Issued amount</td>
<td>{{ formatAmount(asset.chain_stats.issued_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td> <td *ngIf="!blindedIssuance; else confidentialTd">{{ formatAmount(asset.chain_stats.issued_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
</tr> </tr>
<tr> <tr>
<td>Burned amount</td> <td>Burned amount</td>
<td>{{ formatAmount(asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td> <td *ngIf="!blindedIssuance; else confidentialTd">{{ formatAmount(asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
</tr> </tr>
<tr *ngIf="!isNativeAsset"> <tr *ngIf="!isNativeAsset">
<td>Circulating amount</td> <td>Circulating amount</td>
<td>{{ formatAmount(asset.chain_stats.issued_amount - asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td> <td *ngIf="!blindedIssuance; else confidentialTd">{{ formatAmount(asset.chain_stats.issued_amount - asset.chain_stats.burned_amount, assetContract[3]) | number: '1.0-' + assetContract[3] }} {{ assetContract[1] }}</td>
</tr> </tr>
<tr *ngIf="isNativeAsset"> <tr *ngIf="isNativeAsset">
<td>Circulating amount</td> <td>Circulating amount</td>
@ -137,4 +137,8 @@
</div> </div>
<br> <br>
<ng-template #confidentialTd>
<td>Confidential</td>
</ng-template>

View File

@ -11,7 +11,7 @@ import { of, merge, Subscription, combineLatest } from 'rxjs';
import { SeoService } from 'src/app/services/seo.service'; import { SeoService } from 'src/app/services/seo.service';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { AssetsService } from 'src/app/services/assets.service'; import { AssetsService } from 'src/app/services/assets.service';
import { formatNumber, moveDec } from 'src/app/bitcoin.utils'; import { moveDec } from 'src/app/bitcoin.utils';
@Component({ @Component({
selector: 'app-asset', selector: 'app-asset',
@ -23,6 +23,7 @@ export class AssetComponent implements OnInit, OnDestroy {
nativeAssetId = environment.nativeAssetId; nativeAssetId = environment.nativeAssetId;
asset: Asset; asset: Asset;
blindedIssuance: boolean;
assetContract: any; assetContract: any;
assetString: string; assetString: string;
isLoadingAsset = true; isLoadingAsset = true;
@ -98,6 +99,10 @@ export class AssetComponent implements OnInit, OnDestroy {
switchMap(([asset, assetsData]) => { switchMap(([asset, assetsData]) => {
this.asset = asset; this.asset = asset;
this.assetContract = assetsData[this.asset.asset_id]; this.assetContract = assetsData[this.asset.asset_id];
if (!this.assetContract) {
this.assetContract = [null, '?', 'Unknown', 0];
}
this.blindedIssuance = this.asset.chain_stats.has_blinded_issuances || this.asset.mempool_stats.has_blinded_issuances;
this.isNativeAsset = asset.asset_id === this.nativeAssetId; this.isNativeAsset = asset.asset_id === this.nativeAssetId;
this.updateChainStats(); this.updateChainStats();
this.websocketService.startTrackAsset(asset.asset_id); this.websocketService.startTrackAsset(asset.asset_id);

View File

@ -4,7 +4,7 @@
<input #instance="ngbTypeahead" [ngbTypeahead]="typeaheadSearch" (selectItem)="itemSelected()" (focus)="focus$.next($any($event).target.value)" (click)="click$.next($any($event).target.value)" formControlName="searchText" type="text" class="form-control" placeholder="TXID, block height, hash or address"> <input #instance="ngbTypeahead" [ngbTypeahead]="typeaheadSearch" (selectItem)="itemSelected()" (focus)="focus$.next($any($event).target.value)" (click)="click$.next($any($event).target.value)" formControlName="searchText" type="text" class="form-control" placeholder="TXID, block height, hash or address">
</div> </div>
<div> <div>
<button type="submit" class="btn btn-block btn-primary"><fa-icon [icon]="['fas', 'search']" [fixedWidth]="true" title="Search"></fa-icon></button> <button [disabled]="isSearching" type="submit" class="btn btn-block btn-primary"><fa-icon [icon]="['fas', 'search']" [fixedWidth]="true" title="Search"></fa-icon></button>
</div> </div>
</div> </div>
</form> </form>

View File

@ -17,6 +17,7 @@ import { NgbTypeahead } from '@ng-bootstrap/ng-bootstrap';
export class SearchFormComponent implements OnInit { export class SearchFormComponent implements OnInit {
network = ''; network = '';
assets: object = {}; assets: object = {};
isSearching = false;
searchForm: FormGroup; searchForm: FormGroup;
@Output() searchTriggered = new EventEmitter(); @Output() searchTriggered = new EventEmitter();
@ -74,25 +75,36 @@ export class SearchFormComponent implements OnInit {
search() { search() {
const searchText = this.searchForm.value.searchText.trim(); const searchText = this.searchForm.value.searchText.trim();
if (searchText) { if (searchText) {
this.isSearching = true;
if (this.regexAddress.test(searchText)) { if (this.regexAddress.test(searchText)) {
this.router.navigate([(this.network ? '/' + this.network : '') + '/address/', searchText]); this.navigate('/address/', searchText);
this.searchTriggered.emit();
} else if (this.regexBlockhash.test(searchText) || this.regexBlockheight.test(searchText)) { } else if (this.regexBlockhash.test(searchText) || this.regexBlockheight.test(searchText)) {
this.router.navigate([(this.network ? '/' + this.network : '') + '/block/', searchText]); this.navigate('/block/', searchText);
this.searchTriggered.emit();
} else if (this.regexTransaction.test(searchText)) { } else if (this.regexTransaction.test(searchText)) {
if (this.network === 'liquid' && this.assets[searchText]) { if (this.network === 'liquid') {
this.router.navigate([(this.network ? '/' + this.network : '') + '/asset/', searchText]); if (this.assets[searchText]) {
this.navigate('/asset/', searchText);
}
this.electrsApiService.getAsset$(searchText)
.subscribe(
() => { this.navigate('/asset/', searchText); },
() => { this.navigate('/tx/', searchText); }
);
} else { } else {
this.router.navigate([(this.network ? '/' + this.network : '') + '/tx/', searchText]); this.navigate('/tx/', searchText);
} }
this.searchTriggered.emit();
} else { } else {
return; this.isSearching = false;
} }
this.searchForm.setValue({
searchText: '',
});
} }
} }
navigate(url: string, searchText: string) {
this.router.navigate([(this.network ? '/' + this.network : '') + url, searchText]);
this.searchTriggered.emit();
this.searchForm.setValue({
searchText: '',
});
this.isSearching = false;
}
} }

View File

@ -129,7 +129,7 @@
</ng-template> </ng-template>
<ng-template #defaultscriptpubkey_type> <ng-template #defaultscriptpubkey_type>
<ng-template [ngIf]="vout.scriptpubkey_type === 'op_return'" [ngIfElse]="otherPubkeyType"> <ng-template [ngIf]="vout.scriptpubkey_type === 'op_return'" [ngIfElse]="otherPubkeyType">
<a placement="bottom" [ngbTooltip]="vout.scriptpubkey | hex2ascii">OP_RETURN</a>&nbsp;<span class="badge badge-secondary scriptmessage">{{ vout.scriptpubkey_asm | hex2ascii }}</span> <a placement="bottom" [ngbTooltip]="vout.scriptpubkey | hex2ascii">OP_RETURN</a>&nbsp;<span *ngIf="vout.scriptpubkey_asm !== 'OP_RETURN'" class="badge badge-secondary scriptmessage">{{ vout.scriptpubkey_asm | hex2ascii }}</span>
</ng-template> </ng-template>
<ng-template #otherPubkeyType>{{ vout.scriptpubkey_type | scriptpubkeyType }}</ng-template> <ng-template #otherPubkeyType>{{ vout.scriptpubkey_type | scriptpubkeyType }}</ng-template>
</ng-template> </ng-template>

View File

@ -14,21 +14,21 @@ source "$NVM_DIR/nvm.sh"
REPO=origin REPO=origin
BRANCH=master BRANCH=master
TAG="${REPO}/${BRANCH}" TAG="${BRANCH}"
[ ! -z "$1" ] && TAG=$1 [ ! -z "$1" ] && TAG=$1
echo "upgrading mempool to ${TAG}" | wall echo "upgrading mempool to ${TAG}" | wall
cd "$HOME/mempool" cd "$HOME/mempool"
git fetch "${REPO}" git fetch "${REPO}"
git reset --hard "${TAG}" git reset --hard "${REPO}/${TAG}"
cd "$HOME/" cd "$HOME/"
for site in mainnet liquid testnet bisq for site in mainnet liquid testnet bisq
do do
cd "$HOME/${site}" cd "$HOME/${site}"
git fetch "${REPO}" git fetch "${REPO}"
git reset --hard "${TAG}" git reset --hard "${REPO}/${TAG}"
hash=$(git rev-parse HEAD) hash=$(git rev-parse HEAD)
if [ "${site}" = "mainnet" ] if [ "${site}" = "mainnet" ]