Merge branch 'master' into wiz/use-svg-logo-for-mempool.space

This commit is contained in:
wiz 2022-06-01 03:22:52 +09:00 committed by GitHub
commit 7f6ea58c74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 773 additions and 913 deletions

View File

@ -17,8 +17,8 @@
"mysql2": "2.3.3", "mysql2": "2.3.3",
"node-worker-threads-pool": "^1.5.1", "node-worker-threads-pool": "^1.5.1",
"socks-proxy-agent": "^6.2.0", "socks-proxy-agent": "^6.2.0",
"typescript": "~4.6.3", "typescript": "~4.7.2",
"ws": "~8.6.0" "ws": "~8.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/compression": "^1.7.2", "@types/compression": "^1.7.2",
@ -1469,9 +1469,9 @@
"integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.6.4", "version": "4.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.2.tgz",
"integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==",
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
@ -1532,9 +1532,9 @@
"dev": true "dev": true
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.6.0", "version": "8.7.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz",
"integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", "integrity": "sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==",
"engines": { "engines": {
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
@ -2708,9 +2708,9 @@
"integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g==" "integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
}, },
"typescript": { "typescript": {
"version": "4.6.4", "version": "4.7.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.2.tgz",
"integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==" "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A=="
}, },
"unpipe": { "unpipe": {
"version": "1.0.0", "version": "1.0.0",
@ -2755,9 +2755,9 @@
"dev": true "dev": true
}, },
"ws": { "ws": {
"version": "8.6.0", "version": "8.7.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz",
"integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", "integrity": "sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==",
"requires": {} "requires": {}
}, },
"yallist": { "yallist": {

View File

@ -36,8 +36,8 @@
"mysql2": "2.3.3", "mysql2": "2.3.3",
"node-worker-threads-pool": "^1.5.1", "node-worker-threads-pool": "^1.5.1",
"socks-proxy-agent": "^6.2.0", "socks-proxy-agent": "^6.2.0",
"typescript": "~4.6.3", "typescript": "~4.7.2",
"ws": "~8.6.0" "ws": "~8.7.0"
}, },
"devDependencies": { "devDependencies": {
"@types/compression": "^1.7.2", "@types/compression": "^1.7.2",

View File

@ -16,6 +16,8 @@ import { prepareBlock } from '../utils/blocks-utils';
import BlocksRepository from '../repositories/BlocksRepository'; import BlocksRepository from '../repositories/BlocksRepository';
import HashratesRepository from '../repositories/HashratesRepository'; import HashratesRepository from '../repositories/HashratesRepository';
import indexer from '../indexer'; import indexer from '../indexer';
import fiatConversion from './fiat-conversion';
import RatesRepository from '../repositories/RatesRepository';
class Blocks { class Blocks {
private blocks: BlockExtended[] = []; private blocks: BlockExtended[] = [];
@ -341,6 +343,9 @@ class Blocks {
await blocksRepository.$saveBlockInDatabase(blockExtended); await blocksRepository.$saveBlockInDatabase(blockExtended);
} }
} }
if (fiatConversion.ratesInitialized === true) {
await RatesRepository.$saveRate(blockExtended.height, fiatConversion.getConversionRates());
}
if (block.height % 2016 === 0) { if (block.height % 2016 === 0) {
this.previousDifficultyRetarget = (block.difficulty - this.currentDifficulty) / this.currentDifficulty * 100; this.previousDifficultyRetarget = (block.difficulty - this.currentDifficulty) / this.currentDifficulty * 100;
@ -426,25 +431,32 @@ class Blocks {
return returnBlocks; return returnBlocks;
} }
if (currentHeight === 0 && Common.indexingEnabled()) {
currentHeight = await blocksRepository.$mostRecentBlockHeight();
}
// Check if block height exist in local cache to skip the hash lookup // Check if block height exist in local cache to skip the hash lookup
const blockByHeight = this.getBlocks().find((b) => b.height === currentHeight); const blockByHeight = this.getBlocks().find((b) => b.height === currentHeight);
let startFromHash: string | null = null; let startFromHash: string | null = null;
if (blockByHeight) { if (blockByHeight) {
startFromHash = blockByHeight.id; startFromHash = blockByHeight.id;
} else { } else if (!Common.indexingEnabled()) {
startFromHash = await bitcoinApi.$getBlockHash(currentHeight); startFromHash = await bitcoinApi.$getBlockHash(currentHeight);
} }
let nextHash = startFromHash; let nextHash = startFromHash;
for (let i = 0; i < limit && currentHeight >= 0; i++) { for (let i = 0; i < limit && currentHeight >= 0; i++) {
let block = this.getBlocks().find((b) => b.height === currentHeight); let block = this.getBlocks().find((b) => b.height === currentHeight);
if (!block && Common.indexingEnabled()) { if (block) {
returnBlocks.push(block);
} else if (Common.indexingEnabled()) {
block = await this.$indexBlock(currentHeight); block = await this.$indexBlock(currentHeight);
} else if (!block) { returnBlocks.push(block);
} else if (nextHash != null) {
block = prepareBlock(await bitcoinApi.$getBlock(nextHash)); block = prepareBlock(await bitcoinApi.$getBlock(nextHash));
nextHash = block.previousblockhash;
returnBlocks.push(block);
} }
returnBlocks.push(block);
nextHash = block.previousblockhash;
currentHeight--; currentHeight--;
} }

View File

@ -4,7 +4,7 @@ import logger from '../logger';
import { Common } from './common'; import { Common } from './common';
class DatabaseMigration { class DatabaseMigration {
private static currentVersion = 18; private static currentVersion = 19;
private queryTimeout = 120000; private queryTimeout = 120000;
private statisticsAddedIndexed = false; private statisticsAddedIndexed = false;
@ -184,6 +184,10 @@ class DatabaseMigration {
if (databaseSchemaVersion < 18 && isBitcoin === true) { if (databaseSchemaVersion < 18 && isBitcoin === true) {
await this.$executeQuery('ALTER TABLE `blocks` ADD INDEX `hash` (`hash`);'); await this.$executeQuery('ALTER TABLE `blocks` ADD INDEX `hash` (`hash`);');
} }
if (databaseSchemaVersion < 19) {
await this.$executeQuery(this.getCreateRatesTableQuery(), await this.$checkIfTableExists('rates'));
}
} catch (e) { } catch (e) {
throw e; throw e;
} }
@ -466,6 +470,14 @@ class DatabaseMigration {
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
} }
private getCreateRatesTableQuery(): string {
return `CREATE TABLE IF NOT EXISTS rates (
height int(10) unsigned NOT NULL,
bisq_rates JSON NOT NULL,
PRIMARY KEY (height)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;`;
}
public async $truncateIndexedData(tables: string[]) { public async $truncateIndexedData(tables: string[]) {
const allowedTables = ['blocks', 'hashrates']; const allowedTables = ['blocks', 'hashrates'];

View File

@ -1,4 +1,3 @@
import config from '../config';
import { MempoolBlock } from '../mempool.interfaces'; import { MempoolBlock } from '../mempool.interfaces';
import { Common } from './common'; import { Common } from './common';
import mempool from './mempool'; import mempool from './mempool';
@ -19,6 +18,7 @@ class FeeApi {
'fastestFee': this.defaultFee, 'fastestFee': this.defaultFee,
'halfHourFee': this.defaultFee, 'halfHourFee': this.defaultFee,
'hourFee': this.defaultFee, 'hourFee': this.defaultFee,
'economyFee': minimumFee,
'minimumFee': minimumFee, 'minimumFee': minimumFee,
}; };
} }
@ -31,6 +31,7 @@ class FeeApi {
'fastestFee': firstMedianFee, 'fastestFee': firstMedianFee,
'halfHourFee': secondMedianFee, 'halfHourFee': secondMedianFee,
'hourFee': thirdMedianFee, 'hourFee': thirdMedianFee,
'economyFee': Math.min(2 * minimumFee, thirdMedianFee),
'minimumFee': minimumFee, 'minimumFee': minimumFee,
}; };
} }

View File

@ -6,12 +6,19 @@ import backendInfo from './backend-info';
import { SocksProxyAgent } from 'socks-proxy-agent'; import { SocksProxyAgent } from 'socks-proxy-agent';
class FiatConversion { class FiatConversion {
private conversionRates: IConversionRates = { private debasingFiatCurrencies = ['AED', 'AUD', 'BDT', 'BHD', 'BMD', 'BRL', 'CAD', 'CHF', 'CLP',
'USD': 0 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'KWD',
}; 'LKR', 'MMK', 'MXN', 'MYR', 'NGN', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SAR', 'SEK',
'SGD', 'THB', 'TRY', 'TWD', 'UAH', 'USD', 'VND', 'ZAR'];
private conversionRates: IConversionRates = {};
private ratesChangedCallback: ((rates: IConversionRates) => void) | undefined; private ratesChangedCallback: ((rates: IConversionRates) => void) | undefined;
public ratesInitialized = false; // If true, it means rates are ready for use
constructor() { } constructor() {
for (const fiat of this.debasingFiatCurrencies) {
this.conversionRates[fiat] = 0;
}
}
public setProgressChangedCallback(fn: (rates: IConversionRates) => void) { public setProgressChangedCallback(fn: (rates: IConversionRates) => void) {
this.ratesChangedCallback = fn; this.ratesChangedCallback = fn;
@ -62,13 +69,14 @@ class FiatConversion {
response = await axios.get(fiatConversionUrl, { headers: headers, timeout: 10000 }); response = await axios.get(fiatConversionUrl, { headers: headers, timeout: 10000 });
} }
const usd = response.data.data.find((item: any) => item.currencyCode === 'USD'); for (const rate of response.data.data) {
if (this.debasingFiatCurrencies.includes(rate.currencyCode) && rate.provider === 'Bisq-Aggregate') {
this.conversionRates[rate.currencyCode] = Math.round(100 * rate.price) / 100;
}
}
this.conversionRates = { this.ratesInitialized = true;
'USD': usd.price, logger.debug(`USD Conversion Rate: ${this.conversionRates.USD}`);
};
logger.debug(`USD Conversion Rate: ${usd.price}`);
if (this.ratesChangedCallback) { if (this.ratesChangedCallback) {
this.ratesChangedCallback(this.conversionRates); this.ratesChangedCallback(this.conversionRates);

View File

@ -94,8 +94,13 @@ class Mining {
poolsStatistics['blockCount'] = blockCount; poolsStatistics['blockCount'] = blockCount;
const totalBlock24h: number = await BlocksRepository.$blockCount(null, '24h'); const totalBlock24h: number = await BlocksRepository.$blockCount(null, '24h');
const lastBlockHashrate = await bitcoinClient.getNetworkHashPs(totalBlock24h);
poolsStatistics['lastEstimatedHashrate'] = lastBlockHashrate; try {
poolsStatistics['lastEstimatedHashrate'] = await bitcoinClient.getNetworkHashPs(totalBlock24h);
} catch (e) {
poolsStatistics['lastEstimatedHashrate'] = 0;
logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate');
}
return poolsStatistics; return poolsStatistics;
} }
@ -118,7 +123,12 @@ class Mining {
const blockCount1w: number = await BlocksRepository.$blockCount(pool.id, '1w'); const blockCount1w: number = await BlocksRepository.$blockCount(pool.id, '1w');
const totalBlock1w: number = await BlocksRepository.$blockCount(null, '1w'); const totalBlock1w: number = await BlocksRepository.$blockCount(null, '1w');
const currentEstimatedkHashrate = await bitcoinClient.getNetworkHashPs(totalBlock24h); let currentEstimatedHashrate = 0;
try {
currentEstimatedHashrate = await bitcoinClient.getNetworkHashPs(totalBlock24h);
} catch (e) {
logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate');
}
return { return {
pool: pool, pool: pool,
@ -132,7 +142,7 @@ class Mining {
'24h': blockCount24h / totalBlock24h, '24h': blockCount24h / totalBlock24h,
'1w': blockCount1w / totalBlock1w, '1w': blockCount1w / totalBlock1w,
}, },
estimatedHashrate: currentEstimatedkHashrate * (blockCount24h / totalBlock24h), estimatedHashrate: currentEstimatedHashrate * (blockCount24h / totalBlock24h),
reportedHashrate: null, reportedHashrate: null,
}; };
} }

View File

@ -13,6 +13,7 @@ import config from '../config';
import transactionUtils from './transaction-utils'; import transactionUtils from './transaction-utils';
import rbfCache from './rbf-cache'; import rbfCache from './rbf-cache';
import difficultyAdjustment from './difficulty-adjustment'; import difficultyAdjustment from './difficulty-adjustment';
import feeApi from './fee-api';
class WebsocketHandler { class WebsocketHandler {
private wss: WebSocket.Server | undefined; private wss: WebSocket.Server | undefined;
@ -236,6 +237,7 @@ class WebsocketHandler {
const rbfTransactions = Common.findRbfTransactions(newTransactions, deletedTransactions); const rbfTransactions = Common.findRbfTransactions(newTransactions, deletedTransactions);
const da = difficultyAdjustment.getDifficultyAdjustment(); const da = difficultyAdjustment.getDifficultyAdjustment();
memPool.handleRbfTransactions(rbfTransactions); memPool.handleRbfTransactions(rbfTransactions);
const recommendedFees = feeApi.getRecommendedFee();
this.wss.clients.forEach(async (client: WebSocket) => { this.wss.clients.forEach(async (client: WebSocket) => {
if (client.readyState !== WebSocket.OPEN) { if (client.readyState !== WebSocket.OPEN) {
@ -249,6 +251,7 @@ class WebsocketHandler {
response['vBytesPerSecond'] = vBytesPerSecond; response['vBytesPerSecond'] = vBytesPerSecond;
response['transactions'] = newTransactions.slice(0, 6).map((tx) => Common.stripTransaction(tx)); response['transactions'] = newTransactions.slice(0, 6).map((tx) => Common.stripTransaction(tx));
response['da'] = da; response['da'] = da;
response['fees'] = recommendedFees;
} }
if (client['want-mempool-blocks']) { if (client['want-mempool-blocks']) {
@ -413,6 +416,7 @@ class WebsocketHandler {
'block': block, 'block': block,
'mempoolInfo': memPool.getMempoolInfo(), 'mempoolInfo': memPool.getMempoolInfo(),
'da': difficultyAdjustment.getDifficultyAdjustment(), 'da': difficultyAdjustment.getDifficultyAdjustment(),
'fees': feeApi.getRecommendedFee(),
}; };
if (mBlocks && client['want-mempool-blocks']) { if (mBlocks && client['want-mempool-blocks']) {

View File

@ -25,8 +25,6 @@ import databaseMigration from './api/database-migration';
import syncAssets from './sync-assets'; import syncAssets from './sync-assets';
import icons from './api/liquid/icons'; import icons from './api/liquid/icons';
import { Common } from './api/common'; import { Common } from './api/common';
import mining from './api/mining';
import HashratesRepository from './repositories/HashratesRepository';
import poolsUpdater from './tasks/pools-updater'; import poolsUpdater from './tasks/pools-updater';
import indexer from './indexer'; import indexer from './indexer';
@ -69,7 +67,7 @@ class Server {
} }
async startServer(worker = false) { async startServer(worker = false) {
logger.debug(`Starting Mempool Server${worker ? ' (worker)' : ''}... (${backendInfo.getShortCommitHash()})`); logger.notice(`Starting Mempool Server${worker ? ' (worker)' : ''}... (${backendInfo.getShortCommitHash()})`);
this.app this.app
.use((req: Request, res: Response, next: NextFunction) => { .use((req: Request, res: Response, next: NextFunction) => {

View File

@ -121,6 +121,19 @@ class BlocksRepository {
} }
} }
/**
* Return most recent block height
*/
public async $mostRecentBlockHeight(): Promise<number> {
try {
const [row] = await DB.query('SELECT MAX(height) as maxHeight from blocks');
return row[0]['maxHeight'];
} catch (e) {
logger.err(`Cannot count blocks for this pool (using offset). Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
/** /**
* Get blocks count for a period * Get blocks count for a period
*/ */
@ -240,8 +253,26 @@ class BlocksRepository {
} }
const params: any[] = []; const params: any[] = [];
let query = ` SELECT *, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp, let query = ` SELECT
previous_block_hash as previousblockhash height,
hash as id,
UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
size,
weight,
tx_count,
coinbase_raw,
difficulty,
fees,
fee_span,
median_fee,
reward,
version,
bits,
nonce,
merkle_root,
previous_block_hash as previousblockhash,
avg_fee,
avg_fee_rate
FROM blocks FROM blocks
WHERE pool_id = ?`; WHERE pool_id = ?`;
params.push(pool.id); params.push(pool.id);
@ -274,11 +305,32 @@ class BlocksRepository {
*/ */
public async $getBlockByHeight(height: number): Promise<object | null> { public async $getBlockByHeight(height: number): Promise<object | null> {
try { try {
const [rows]: any[] = await DB.query(` const [rows]: any[] = await DB.query(`SELECT
SELECT *, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp, height,
pools.id as pool_id, pools.name as pool_name, pools.link as pool_link, pools.slug as pool_slug, hash as id,
pools.addresses as pool_addresses, pools.regexes as pool_regexes, UNIX_TIMESTAMP(blocks.blockTimestamp) as blockTimestamp,
previous_block_hash as previousblockhash size,
weight,
tx_count,
coinbase_raw,
difficulty,
pools.id as pool_id,
pools.name as pool_name,
pools.link as pool_link,
pools.slug as pool_slug,
pools.addresses as pool_addresses,
pools.regexes as pool_regexes,
fees,
fee_span,
median_fee,
reward,
version,
bits,
nonce,
merkle_root,
previous_block_hash as previousblockhash,
avg_fee,
avg_fee_rate
FROM blocks FROM blocks
JOIN pools ON blocks.pool_id = pools.id JOIN pools ON blocks.pool_id = pools.id
WHERE height = ${height}; WHERE height = ${height};

View File

@ -0,0 +1,21 @@
import DB from '../database';
import logger from '../logger';
import { IConversionRates } from '../mempool.interfaces';
class RatesRepository {
public async $saveRate(height: number, rates: IConversionRates) {
try {
await DB.query(`INSERT INTO rates(height, bisq_rates) VALUE (?, ?)`, [height, JSON.stringify(rates)]);
} catch (e: any) {
if (e.errno === 1062) { // ER_DUP_ENTRY - This scenario is possible upon node backend restart
logger.debug(`Rate already exists for block ${height}, ignoring`);
} else {
logger.err(`Cannot save exchange rate into db for block ${height} Reason: ` + (e instanceof Error ? e.message : e));
throw e;
}
}
}
}
export default new RatesRepository();

View File

@ -619,6 +619,14 @@ class Routes {
} }
public async $getHistoricalHashrate(req: Request, res: Response) { public async $getHistoricalHashrate(req: Request, res: Response) {
let currentHashrate = 0, currentDifficulty = 0;
try {
currentHashrate = await bitcoinClient.getNetworkHashPs();
currentDifficulty = await bitcoinClient.getDifficulty();
} catch (e) {
logger.debug('Bitcoin Core is not available, using zeroed value for current hashrate and difficulty');
}
try { try {
const hashrates = await HashratesRepository.$getNetworkDailyHashrate(req.params.interval); const hashrates = await HashratesRepository.$getNetworkDailyHashrate(req.params.interval);
const difficulty = await BlocksRepository.$getBlocksDifficulty(req.params.interval); const difficulty = await BlocksRepository.$getBlocksDifficulty(req.params.interval);
@ -630,8 +638,8 @@ class Routes {
res.json({ res.json({
hashrates: hashrates, hashrates: hashrates,
difficulty: difficulty, difficulty: difficulty,
currentHashrate: await bitcoinClient.getNetworkHashPs(), currentHashrate: currentHashrate,
currentDifficulty: await bitcoinClient.getDifficulty(), currentDifficulty: currentDifficulty,
}); });
} catch (e) { } catch (e) {
res.status(500).send(e instanceof Error ? e.message : e); res.status(500).send(e instanceof Error ? e.message : e);

View File

@ -16,7 +16,7 @@ class PoolsUpdater {
} }
public async updatePoolsJson() { public async updatePoolsJson() {
if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false) { if (['mainnet', 'testnet', 'signet'].includes(config.MEMPOOL.NETWORK) === false || config.DATABASE.ENABLED === false) {
return; return;
} }

File diff suppressed because it is too large Load Diff

View File

@ -73,10 +73,10 @@
"@angular/platform-browser-dynamic": "~13.3.10", "@angular/platform-browser-dynamic": "~13.3.10",
"@angular/platform-server": "~13.3.10", "@angular/platform-server": "~13.3.10",
"@angular/router": "~13.3.10", "@angular/router": "~13.3.10",
"@fortawesome/angular-fontawesome": "~0.10.1", "@fortawesome/angular-fontawesome": "~0.10.2",
"@fortawesome/fontawesome-common-types": "~0.3.0", "@fortawesome/fontawesome-common-types": "~6.1.1",
"@fortawesome/fontawesome-svg-core": "~1.3.0", "@fortawesome/fontawesome-svg-core": "~6.1.1",
"@fortawesome/free-solid-svg-icons": "~6.0.0", "@fortawesome/free-solid-svg-icons": "~6.1.1",
"@juggle/resize-observer": "^3.3.1", "@juggle/resize-observer": "^3.3.1",
"@mempool/mempool.js": "2.3.0", "@mempool/mempool.js": "2.3.0",
"@ng-bootstrap/ng-bootstrap": "^11.0.0", "@ng-bootstrap/ng-bootstrap": "^11.0.0",
@ -93,24 +93,24 @@
"ngx-echarts": "8.0.1", "ngx-echarts": "8.0.1",
"ngx-infinite-scroll": "^10.0.1", "ngx-infinite-scroll": "^10.0.1",
"qrcode": "1.5.0", "qrcode": "1.5.0",
"rxjs": "^6.6.7", "rxjs": "~7.5.5",
"tinyify": "^3.0.0", "tinyify": "^3.0.0",
"tlite": "^0.1.9", "tlite": "^0.1.9",
"tslib": "^2.2.0", "tslib": "~2.4.0",
"zone.js": "~0.11.4" "zone.js": "~0.11.5"
}, },
"devDependencies": { "devDependencies": {
"@angular/compiler-cli": "~13.3.10", "@angular/compiler-cli": "~13.3.10",
"@angular/language-service": "~13.3.10", "@angular/language-service": "~13.3.10",
"@nguniversal/builders": "~13.1.0", "@nguniversal/builders": "~13.1.1",
"@types/express": "^4.17.0", "@types/express": "^4.17.0",
"@types/jasmine": "~3.6.0", "@types/jasmine": "~4.0.3",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.10",
"@types/node": "^12.11.1", "@types/node": "^12.11.1",
"codelyzer": "^6.0.1", "codelyzer": "~6.0.2",
"http-proxy-middleware": "^1.0.5", "http-proxy-middleware": "^1.0.5",
"jasmine-core": "~3.6.0", "jasmine-core": "~4.1.0",
"jasmine-spec-reporter": "~5.0.0", "jasmine-spec-reporter": "~7.0.0",
"karma": "~6.3.19", "karma": "~6.3.19",
"karma-chrome-launcher": "~3.1.0", "karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3", "karma-coverage": "~2.0.3",
@ -118,7 +118,7 @@
"karma-jasmine-html-reporter": "^1.5.0", "karma-jasmine-html-reporter": "^1.5.0",
"ts-node": "~8.3.0", "ts-node": "~8.3.0",
"tslint": "~6.1.0", "tslint": "~6.1.0",
"typescript": "~4.4.4" "typescript": "~4.6.4"
}, },
"optionalDependencies": { "optionalDependencies": {
"@cypress/schematic": "^1.3.0", "@cypress/schematic": "^1.3.0",

View File

@ -19,7 +19,7 @@
<a [href]="env.MEMPOOL_WEBSITE_URL + urlLanguage + '/signet'" ngbDropdownItem *ngIf="env.SIGNET_ENABLED" class="signet"><img src="./resources/signet-logo.png" style="width: 30px;" class="mr-1"> Signet</a> <a [href]="env.MEMPOOL_WEBSITE_URL + urlLanguage + '/signet'" ngbDropdownItem *ngIf="env.SIGNET_ENABLED" class="signet"><img src="./resources/signet-logo.png" style="width: 30px;" class="mr-1"> Signet</a>
<a [href]="env.MEMPOOL_WEBSITE_URL + urlLanguage + '/testnet'" ngbDropdownItem *ngIf="env.TESTNET_ENABLED" class="testnet"><img src="./resources/testnet-logo.png" style="width: 30px;" class="mr-1"> Testnet</a> <a [href]="env.MEMPOOL_WEBSITE_URL + urlLanguage + '/testnet'" ngbDropdownItem *ngIf="env.TESTNET_ENABLED" class="testnet"><img src="./resources/testnet-logo.png" style="width: 30px;" class="mr-1"> Testnet</a>
<h6 class="dropdown-header" i18n="master-page.layer2-networks-header">Layer 2 Networks</h6> <h6 class="dropdown-header" i18n="master-page.layer2-networks-header">Layer 2 Networks</h6>
<button ngbDropdownItem class="mainnet active" routerLink="/"><img src="./resources/bisq-logo.png" style="width: 30px;" class="mr-1"> Bisq</button> <a ngbDropdownItem class="mainnet active" routerLink="/"><img src="./resources/bisq-logo.png" style="width: 30px;" class="mr-1"> Bisq</a>
<a [href]="env.LIQUID_WEBSITE_URL + urlLanguage" ngbDropdownItem *ngIf="env.LIQUID_ENABLED" class="liquid"><img src="./resources/liquid-logo.png" style="width: 30px;" class="mr-1"> Liquid</a> <a [href]="env.LIQUID_WEBSITE_URL + urlLanguage" ngbDropdownItem *ngIf="env.LIQUID_ENABLED" class="liquid"><img src="./resources/liquid-logo.png" style="width: 30px;" class="mr-1"> Liquid</a>
<a [href]="env.LIQUID_WEBSITE_URL + urlLanguage + '/testnet'" ngbDropdownItem *ngIf="env.LIQUID_TESTNET_ENABLED" class="liquidtestnet"><img src="./resources/liquidtestnet-logo.png" style="width: 30px;" class="mr-1"> Liquid Testnet</a> <a [href]="env.LIQUID_WEBSITE_URL + urlLanguage + '/testnet'" ngbDropdownItem *ngIf="env.LIQUID_TESTNET_ENABLED" class="liquidtestnet"><img src="./resources/liquidtestnet-logo.png" style="width: 30px;" class="mr-1"> Liquid Testnet</a>
</div> </div>

View File

@ -22,7 +22,7 @@
<tbody *ngIf="blocks$ | async as blocks; else skeleton" [style]="isLoading ? 'opacity: 0.75' : ''"> <tbody *ngIf="blocks$ | async as blocks; else skeleton" [style]="isLoading ? 'opacity: 0.75' : ''">
<tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock"> <tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock">
<td class="text-left" [class]="widget ? 'widget' : ''"> <td class="text-left" [class]="widget ? 'widget' : ''">
<a [routerLink]="['/block' | relativeUrl, block.height]">{{ block.height }}</a> <a [routerLink]="['/block' | relativeUrl, block.id]" [state]="{ data: { block: block } }">{{ block.height }}</a>
</td> </td>
<td *ngIf="indexingAvailable" class="pool text-left" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}"> <td *ngIf="indexingAvailable" class="pool text-left" [ngClass]="{'widget': widget, 'legacy': !indexingAvailable}">
<div class="tooltip-custom"> <div class="tooltip-custom">

View File

@ -1,21 +1,21 @@
<div class="fee-estimation-wrapper"> <div class="fee-estimation-wrapper">
<div class="fee-estimation-container" *ngIf="(isLoadingWebSocket$ | async) === false && (feeEstimations$ | async) as feeEstimations; else loadingFees"> <div class="fee-estimation-container" *ngIf="(isLoadingWebSocket$ | async) === false && (recommendedFees$ | async) as recommendedFees; else loadingFees">
<div class="item"> <div class="item">
<h5 class="card-title" i18n="fees-box.low-priority">Low priority</h5> <h5 class="card-title" i18n="fees-box.low-priority">Low priority</h5>
<div class="card-text" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom"> <div class="card-text" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom">
<div class="fee-text">{{ feeEstimations.hourFee }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></div> <span class="fiat"><app-fiat [value]="feeEstimations.hourFee * 140" ></app-fiat></span> <div class="fee-text">{{ recommendedFees.hourFee }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></div> <span class="fiat"><app-fiat [value]="recommendedFees.hourFee * 140" ></app-fiat></span>
</div> </div>
</div> </div>
<div class="item"> <div class="item">
<h5 class="card-title" i18n="fees-box.medium-priority">Medium priority</h5> <h5 class="card-title" i18n="fees-box.medium-priority">Medium priority</h5>
<div class="card-text" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom"> <div class="card-text" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom">
<div class="fee-text">{{ feeEstimations.halfHourFee }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></div> <span class="fiat"><app-fiat [value]="feeEstimations.halfHourFee * 140" ></app-fiat></span> <div class="fee-text">{{ recommendedFees.halfHourFee }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></div> <span class="fiat"><app-fiat [value]="recommendedFees.halfHourFee * 140" ></app-fiat></span>
</div> </div>
</div> </div>
<div class="item"> <div class="item">
<h5 class="card-title" i18n="fees-box.high-priority">High priority</h5> <h5 class="card-title" i18n="fees-box.high-priority">High priority</h5>
<div class="card-text" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom"> <div class="card-text" i18n-ngbTooltip="Transaction fee tooltip" ngbTooltip="Based on average native segwit transaction of 140 vBytes" placement="bottom">
<div class="fee-text">{{ feeEstimations.fastestFee }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></div> <span class="fiat"><app-fiat [value]="feeEstimations.fastestFee * 140" ></app-fiat></span> <div class="fee-text">{{ recommendedFees.fastestFee }} <span i18n="shared.sat-vbyte|sat/vB">sat/vB</span></div> <span class="fiat"><app-fiat [value]="recommendedFees.fastestFee * 140" ></app-fiat></span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,8 +1,8 @@
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
import { StateService } from 'src/app/services/state.service'; import { StateService } from 'src/app/services/state.service';
import { map, filter } from 'rxjs/operators'; import { map, filter, tap } from 'rxjs/operators';
import { merge, Observable } from 'rxjs'; import { merge, Observable } from 'rxjs';
import { MempoolBlock } from 'src/app/interfaces/websocket.interface'; import { MempoolBlock, Recommendedfees } from 'src/app/interfaces/websocket.interface';
interface FeeEstimations { interface FeeEstimations {
fastestFee: number; fastestFee: number;
@ -17,8 +17,8 @@ interface FeeEstimations {
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class FeesBoxComponent implements OnInit { export class FeesBoxComponent implements OnInit {
feeEstimations$: Observable<FeeEstimations>;
isLoadingWebSocket$: Observable<boolean>; isLoadingWebSocket$: Observable<boolean>;
recommendedFees$: Observable<Recommendedfees>;
defaultFee: number; defaultFee: number;
constructor( constructor(
@ -29,40 +29,6 @@ export class FeesBoxComponent implements OnInit {
this.defaultFee = this.stateService.network === 'liquid' || this.stateService.network === 'liquidtestnet' ? 0.1 : 1; this.defaultFee = this.stateService.network === 'liquid' || this.stateService.network === 'liquidtestnet' ? 0.1 : 1;
this.isLoadingWebSocket$ = this.stateService.isLoadingWebSocket$; this.isLoadingWebSocket$ = this.stateService.isLoadingWebSocket$;
this.feeEstimations$ = this.stateService.mempoolBlocks$ this.recommendedFees$ = this.stateService.recommendedFees$;
.pipe(
map((pBlocks) => {
if (!pBlocks.length) {
return {
'fastestFee': this.defaultFee,
'halfHourFee': this.defaultFee,
'hourFee': this.defaultFee,
};
}
const firstMedianFee = this.optimizeMedianFee(pBlocks[0], pBlocks[1]);
const secondMedianFee = pBlocks[1] ? this.optimizeMedianFee(pBlocks[1], pBlocks[2], firstMedianFee) : this.defaultFee;
const thirdMedianFee = pBlocks[2] ? this.optimizeMedianFee(pBlocks[2], pBlocks[3], secondMedianFee) : this.defaultFee;
return {
'fastestFee': firstMedianFee,
'halfHourFee': secondMedianFee,
'hourFee': thirdMedianFee,
};
})
);
} }
private optimizeMedianFee(pBlock: MempoolBlock, nextBlock: MempoolBlock | undefined, previousFee?: number): number {
const useFee = previousFee ? (pBlock.medianFee + previousFee) / 2 : pBlock.medianFee;
if (pBlock.blockVSize <= 500000) {
return this.defaultFee;
}
if (pBlock.blockVSize <= 950000 && !nextBlock) {
const multiplier = (pBlock.blockVSize - 500000) / 500000;
return Math.max(Math.round(useFee * multiplier), this.defaultFee);
}
return Math.ceil(useFee);
}
} }

View File

@ -21,8 +21,8 @@
<a [href]="env.MEMPOOL_WEBSITE_URL + urlLanguage + '/testnet'" ngbDropdownItem *ngIf="env.TESTNET_ENABLED" class="testnet"><img src="./resources/testnet-logo.png" style="width: 30px;" class="mr-1"> Testnet</a> <a [href]="env.MEMPOOL_WEBSITE_URL + urlLanguage + '/testnet'" ngbDropdownItem *ngIf="env.TESTNET_ENABLED" class="testnet"><img src="./resources/testnet-logo.png" style="width: 30px;" class="mr-1"> Testnet</a>
<h6 class="dropdown-header" i18n="master-page.layer2-networks-header">Layer 2 Networks</h6> <h6 class="dropdown-header" i18n="master-page.layer2-networks-header">Layer 2 Networks</h6>
<a [href]="env.BISQ_WEBSITE_URL + urlLanguage" ngbDropdownItem class="mainnet"><img src="./resources/bisq-logo.png" style="width: 30px;" class="mr-1"> Bisq</a> <a [href]="env.BISQ_WEBSITE_URL + urlLanguage" ngbDropdownItem class="mainnet"><img src="./resources/bisq-logo.png" style="width: 30px;" class="mr-1"> Bisq</a>
<button ngbDropdownItem class="liquid" [class.active]="network.val === 'liquid'" routerLink="/"><img src="./resources/liquid-logo.png" style="width: 30px;" class="mr-1"> Liquid</button> <a ngbDropdownItem class="liquid mr-1" [class.active]="network.val === 'liquid'" routerLink="/"><img src="./resources/liquid-logo.png" style="width: 30px;"> Liquid</a>
<button ngbDropdownItem *ngIf="env.LIQUID_TESTNET_ENABLED" class="liquidtestnet" [class.active]="network.val === 'liquidtestnet'" routerLink="/testnet"><img src="./resources/liquidtestnet-logo.png" style="width: 30px;" class="mr-1"> Liquid Testnet</button> <a ngbDropdownItem *ngIf="env.LIQUID_TESTNET_ENABLED" class="liquidtestnet" [class.active]="network.val === 'liquidtestnet'" routerLink="/testnet"><img src="./resources/liquidtestnet-logo.png" style="width: 30px;" class="mr-1"> Liquid Testnet</a>
</div> </div>
</div> </div>

View File

@ -17,9 +17,9 @@
<img src="./resources/{{ network.val === '' ? 'bitcoin' : network.val }}-logo.png" style="width: 25px; height: 25px;" class="mr-1" [alt]="(network.val === '' ? 'bitcoin' : network.val) + ' logo'"> <img src="./resources/{{ network.val === '' ? 'bitcoin' : network.val }}-logo.png" style="width: 25px; height: 25px;" class="mr-1" [alt]="(network.val === '' ? 'bitcoin' : network.val) + ' logo'">
</button> </button>
<div ngbDropdownMenu [ngClass]="{'dropdown-menu-right' : isMobile}"> <div ngbDropdownMenu [ngClass]="{'dropdown-menu-right' : isMobile}">
<button ngbDropdownItem class="mainnet" routerLink="/"><img src="./resources/bitcoin-logo.png" style="width: 30px;" class="mr-1" alt="bitcoin logo"> Mainnet</button> <a ngbDropdownItem class="mainnet" routerLink="/"><img src="./resources/bitcoin-logo.png" style="width: 30px;" class="mainnet mr-1" alt="bitcoin logo"> Mainnet</a>
<button ngbDropdownItem *ngIf="env.SIGNET_ENABLED" class="signet" [class.active]="network.val === 'signet'" routerLink="/signet"><img src="./resources/signet-logo.png" style="width: 30px;" class="mr-1" alt="signet logo"> Signet</button> <a ngbDropdownItem *ngIf="env.SIGNET_ENABLED" class="signet" [class.active]="network.val === 'signet'" routerLink="/signet"><img src="./resources/signet-logo.png" style="width: 30px;" class="signet mr-1" alt="logo"> Signet</a>
<button ngbDropdownItem *ngIf="env.TESTNET_ENABLED" class="testnet" [class.active]="network.val === 'testnet'" routerLink="/testnet"><img src="./resources/testnet-logo.png" style="width: 30px;" class="mr-1" alt="testnet logo"> Testnet</button> <a ngbDropdownItem *ngIf="env.TESTNET_ENABLED" class="testnet" [class.active]="network.val === 'testnet'" routerLink="/testnet"><img src="./resources/testnet-logo.png" style="width: 30px;" class="mr-1" alt="testnet logo"> Testnet</a>
<h6 *ngIf="env.LIQUID_ENABLED || env.BISQ_ENABLED" class="dropdown-header" i18n="master-page.layer2-networks-header">Layer 2 Networks</h6> <h6 *ngIf="env.LIQUID_ENABLED || env.BISQ_ENABLED" class="dropdown-header" i18n="master-page.layer2-networks-header">Layer 2 Networks</h6>
<a [href]="env.BISQ_WEBSITE_URL + urlLanguage" ngbDropdownItem *ngIf="env.BISQ_ENABLED" class="bisq"><img src="./resources/bisq-logo.png" style="width: 30px;" class="mr-1" alt="bisq logo"> Bisq</a> <a [href]="env.BISQ_WEBSITE_URL + urlLanguage" ngbDropdownItem *ngIf="env.BISQ_ENABLED" class="bisq"><img src="./resources/bisq-logo.png" style="width: 30px;" class="mr-1" alt="bisq logo"> Bisq</a>
<a [href]="env.LIQUID_WEBSITE_URL + urlLanguage" ngbDropdownItem *ngIf="env.LIQUID_ENABLED" class="liquid" [class.active]="network.val === 'liquid'"><img src="./resources/liquid-logo.png" style="width: 30px;" class="mr-1" alt="liquid mainnet logo"> Liquid</a> <a [href]="env.LIQUID_WEBSITE_URL + urlLanguage" ngbDropdownItem *ngIf="env.LIQUID_ENABLED" class="liquid" [class.active]="network.val === 'liquid'"><img src="./resources/liquid-logo.png" style="width: 30px;" class="mr-1" alt="liquid mainnet logo"> Liquid</a>

View File

@ -221,8 +221,7 @@
<tbody [style]="isLoading ? 'opacity: 0.75' : ''"> <tbody [style]="isLoading ? 'opacity: 0.75' : ''">
<tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock"> <tr *ngFor="let block of blocks; let i= index; trackBy: trackByBlock">
<td class="height"> <td class="height">
<a [routerLink]="['/block' | relativeUrl, block.height]">{{ block.height <a [routerLink]="['/block' | relativeUrl, block.id]">{{ block.height }}</a>
}}</a>
</td> </td>
<td class="timestamp"> <td class="timestamp">
&lrm;{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }} &lrm;{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }}

View File

@ -66,13 +66,16 @@
</ng-template> </ng-template>
</ng-template> </ng-template>
<ng-template #defaultAddress> <ng-template #defaultAddress>
<a [routerLink]="['/address/' | relativeUrl, vin.prevout.scriptpubkey_address]" title="{{ vin.prevout.scriptpubkey_address }}"> <a *ngIf="vin.prevout.scriptpubkey_address; else vinScriptPubkeyType" [routerLink]="['/address/' | relativeUrl, vin.prevout.scriptpubkey_address]" title="{{ vin.prevout.scriptpubkey_address }}">
<span class="d-block d-lg-none">{{ vin.prevout.scriptpubkey_address | shortenString : 16 }}</span> <span class="d-block d-lg-none">{{ vin.prevout.scriptpubkey_address | shortenString : 16 }}</span>
<span class="d-none d-lg-flex justify-content-start"> <span class="d-none d-lg-flex justify-content-start">
<span class="addr-left flex-grow-1" [style]="vin.prevout.scriptpubkey_address.length > 40 ? 'max-width: 235px' : ''">{{ vin.prevout.scriptpubkey_address }}</span> <span class="addr-left flex-grow-1" [style]="vin.prevout.scriptpubkey_address.length > 40 ? 'max-width: 235px' : ''">{{ vin.prevout.scriptpubkey_address }}</span>
<span *ngIf="vin.prevout.scriptpubkey_address.length > 40" class="addr-right">{{ vin.prevout.scriptpubkey_address | capAddress: 40: 10 }}</span> <span *ngIf="vin.prevout.scriptpubkey_address.length > 40" class="addr-right">{{ vin.prevout.scriptpubkey_address | capAddress: 40: 10 }}</span>
</span> </span>
</a> </a>
<ng-template #vinScriptPubkeyType>
{{ vin.prevout.scriptpubkey_type?.toUpperCase() }}
</ng-template>
<div> <div>
<app-address-labels [vin]="vin"></app-address-labels> <app-address-labels [vin]="vin"></app-address-labels>
</div> </div>

View File

@ -30,7 +30,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
latestBlock$: Observable<BlockExtended>; latestBlock$: Observable<BlockExtended>;
outspendsSubscription: Subscription; outspendsSubscription: Subscription;
refreshOutspends$: ReplaySubject<object> = new ReplaySubject(); refreshOutspends$: ReplaySubject<{ [str: string]: Observable<Outspend[]>}> = new ReplaySubject();
showDetails$ = new BehaviorSubject<boolean>(false); showDetails$ = new BehaviorSubject<boolean>(false);
outspends: Outspend[][] = []; outspends: Outspend[][] = [];
assetsMinimal: any; assetsMinimal: any;

View File

@ -4470,6 +4470,7 @@ export const restApiDocsData = [
fastestFee: 1, fastestFee: 1,
halfHourFee: 1, halfHourFee: 1,
hourFee: 1, hourFee: 1,
economyFee: 1,
minimumFee: 1 minimumFee: 1
}` }`
}, },
@ -4481,6 +4482,7 @@ export const restApiDocsData = [
fastestFee: 1, fastestFee: 1,
halfHourFee: 1, halfHourFee: 1,
hourFee: 1, hourFee: 1,
economyFee: 1,
minimumFee: 1 minimumFee: 1
}` }`
}, },
@ -4492,6 +4494,7 @@ export const restApiDocsData = [
fastestFee: 1, fastestFee: 1,
halfHourFee: 1, halfHourFee: 1,
hourFee: 1, hourFee: 1,
economyFee: 1,
minimumFee: 1 minimumFee: 1
}` }`
}, },
@ -4503,7 +4506,8 @@ export const restApiDocsData = [
fastestFee: 0.1, fastestFee: 0.1,
halfHourFee: 0.1, halfHourFee: 0.1,
hourFee: 0.1, hourFee: 0.1,
minimumFee: 1 economyFee: 0.1,
minimumFee: 0.1
}` }`
}, },
codeSampleLiquidTestnet: { codeSampleLiquidTestnet: {
@ -4514,7 +4518,8 @@ export const restApiDocsData = [
fastestFee: 0.1, fastestFee: 0.1,
halfHourFee: 0.1, halfHourFee: 0.1,
hourFee: 0.1, hourFee: 0.1,
minimumFee: 1 economyFee: 0.1,
minimumFee: 0.1
}` }`
}, },
codeSampleBisq: emptyCodeSample, codeSampleBisq: emptyCodeSample,

View File

@ -1,7 +1,6 @@
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core'; import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { Env, StateService } from '../../services/state.service'; import { Env, StateService } from '../../services/state.service';
import { Observable, merge, of } from 'rxjs'; import { Observable, merge, of } from 'rxjs';
import { SeoService } from '../../services/seo.service';
import { tap } from 'rxjs/operators'; import { tap } from 'rxjs/operators';
import { ActivatedRoute } from "@angular/router"; import { ActivatedRoute } from "@angular/router";
import { faqData, restApiDocsData, wsApiDocsData } from './api-docs-data'; import { faqData, restApiDocsData, wsApiDocsData } from './api-docs-data';
@ -27,7 +26,6 @@ export class ApiDocsComponent implements OnInit {
constructor( constructor(
private stateService: StateService, private stateService: StateService,
private seoService: SeoService,
private route: ActivatedRoute, private route: ActivatedRoute,
) { } ) { }
@ -45,7 +43,6 @@ export class ApiDocsComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.env = this.stateService.env; this.env = this.stateService.env;
this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`);
this.network$ = merge(of(''), this.stateService.networkChanged$).pipe( this.network$ = merge(of(''), this.stateService.networkChanged$).pipe(
tap((network: string) => { tap((network: string) => {
if (this.env.BASE_MODULE === 'mempool' && network !== '') { if (this.env.BASE_MODULE === 'mempool' && network !== '') {

View File

@ -2,6 +2,7 @@ import { Component, OnInit, HostBinding } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { Env, StateService } from '../../services/state.service'; import { Env, StateService } from '../../services/state.service';
import { WebsocketService } from '../../services/websocket.service'; import { WebsocketService } from '../../services/websocket.service';
import { SeoService } from '../../services/seo.service';
@Component({ @Component({
selector: 'app-docs', selector: 'app-docs',
@ -21,6 +22,7 @@ export class DocsComponent implements OnInit {
private route: ActivatedRoute, private route: ActivatedRoute,
private stateService: StateService, private stateService: StateService,
private websocket: WebsocketService, private websocket: WebsocketService,
private seoService: SeoService,
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
@ -28,10 +30,13 @@ export class DocsComponent implements OnInit {
const url = this.route.snapshot.url; const url = this.route.snapshot.url;
if (url[0].path === "faq" ) { if (url[0].path === "faq" ) {
this.activeTab = 0; this.activeTab = 0;
this.seoService.setTitle($localize`:@@docs.faq.button-title:FAQ`);
} else if( url[1].path === "rest" ) { } else if( url[1].path === "rest" ) {
this.activeTab = 1; this.activeTab = 1;
this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`);
} else { } else {
this.activeTab = 2; this.activeTab = 2;
this.seoService.setTitle($localize`:@@e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4:API`);
} }
this.env = this.stateService.env; this.env = this.stateService.env;

View File

@ -21,6 +21,7 @@ export interface WebsocketResponse {
loadingIndicators?: ILoadingIndicators; loadingIndicators?: ILoadingIndicators;
backendInfo?: IBackendInfo; backendInfo?: IBackendInfo;
da?: DifficultyAdjustment; da?: DifficultyAdjustment;
fees?: Recommendedfees;
'track-tx'?: string; 'track-tx'?: string;
'track-address'?: string; 'track-address'?: string;
'track-asset'?: string; 'track-asset'?: string;
@ -65,3 +66,11 @@ export interface IBackendInfo {
gitCommit: string; gitCommit: string;
version: string; version: string;
} }
export interface Recommendedfees {
fastestFee: number;
halfHourFee: number;
hourFee: number;
minimumFee: number;
economyFee: number;
}

View File

@ -1,7 +1,7 @@
import { Inject, Injectable, PLATFORM_ID } from '@angular/core'; import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { ReplaySubject, BehaviorSubject, Subject, fromEvent, Observable } from 'rxjs'; import { ReplaySubject, BehaviorSubject, Subject, fromEvent, Observable } from 'rxjs';
import { Transaction } from '../interfaces/electrs.interface'; import { Transaction } from '../interfaces/electrs.interface';
import { IBackendInfo, MempoolBlock, MempoolInfo, ReplacedTransaction, TransactionStripped } from '../interfaces/websocket.interface'; import { IBackendInfo, MempoolBlock, MempoolInfo, Recommendedfees, ReplacedTransaction, TransactionStripped } from '../interfaces/websocket.interface';
import { BlockExtended, DifficultyAdjustment, OptimizedMempoolStats } from '../interfaces/node-api.interface'; import { BlockExtended, DifficultyAdjustment, OptimizedMempoolStats } from '../interfaces/node-api.interface';
import { Router, NavigationStart } from '@angular/router'; import { Router, NavigationStart } from '@angular/router';
import { isPlatformBrowser } from '@angular/common'; import { isPlatformBrowser } from '@angular/common';
@ -90,6 +90,7 @@ export class StateService {
previousRetarget$ = new ReplaySubject<number>(1); previousRetarget$ = new ReplaySubject<number>(1);
backendInfo$ = new ReplaySubject<IBackendInfo>(1); backendInfo$ = new ReplaySubject<IBackendInfo>(1);
loadingIndicators$ = new ReplaySubject<ILoadingIndicators>(1); loadingIndicators$ = new ReplaySubject<ILoadingIndicators>(1);
recommendedFees$ = new ReplaySubject<Recommendedfees>(1);
live2Chart$ = new Subject<OptimizedMempoolStats>(); live2Chart$ = new Subject<OptimizedMempoolStats>();

View File

@ -263,6 +263,10 @@ export class WebsocketService {
this.stateService.difficultyAdjustment$.next(response.da); this.stateService.difficultyAdjustment$.next(response.da);
} }
if (response.fees) {
this.stateService.recommendedFees$.next(response.fees);
}
if (response.backendInfo) { if (response.backendInfo) {
this.stateService.backendInfo$.next(response.backendInfo); this.stateService.backendInfo$.next(response.backendInfo);

View File

@ -3934,13 +3934,6 @@
</context-group> </context-group>
<note priority="1" from="description">api-docs.websocket.websocket</note> <note priority="1" from="description">api-docs.websocket.websocket</note>
</trans-unit> </trans-unit>
<trans-unit id="e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4" datatype="html">
<source>API</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/docs/api-docs/api-docs.component.ts</context>
<context context-type="linenumber">48</context>
</context-group>
</trans-unit>
<trans-unit id="0a668c1c2a17e557a18fc06619998e002f50df1e" datatype="html"> <trans-unit id="0a668c1c2a17e557a18fc06619998e002f50df1e" datatype="html">
<source>Code Example</source> <source>Code Example</source>
<context-group purpose="location"> <context-group purpose="location">
@ -3973,6 +3966,24 @@
</context-group> </context-group>
<note priority="1" from="description">API Docs API response</note> <note priority="1" from="description">API Docs API response</note>
</trans-unit> </trans-unit>
<trans-unit id="docs.faq.button-title" datatype="html">
<source>FAQ</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/docs/docs/docs.component.ts</context>
<context context-type="linenumber">33</context>
</context-group>
</trans-unit>
<trans-unit id="e351b40b3869a5c7d19c3d4918cb1ac7aaab95c4" datatype="html">
<source>API</source>
<context-group purpose="location">
<context context-type="sourcefile">src/app/docs/docs/docs.component.ts</context>
<context context-type="linenumber">36</context>
</context-group>
<context-group purpose="location">
<context context-type="sourcefile">src/app/docs/docs/docs.component.ts</context>
<context context-type="linenumber">39</context>
</context-group>
</trans-unit>
<trans-unit id="date-base.year" datatype="html"> <trans-unit id="date-base.year" datatype="html">
<source><x id="DATE" equiv-text="counter"/> year</source> <source><x id="DATE" equiv-text="counter"/> year</source>
<context-group purpose="location"> <context-group purpose="location">