diff --git a/backend/package-lock.json b/backend/package-lock.json index 3e9e31988..b3b659459 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -17,7 +17,7 @@ "crypto-js": "~4.2.0", "express": "~4.18.2", "maxmind": "~4.3.11", - "mysql2": "~3.6.0", + "mysql2": "~3.7.0", "redis": "^4.6.6", "rust-gbt": "file:./rust-gbt", "socks-proxy-agent": "~7.0.0", @@ -6110,9 +6110,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/mysql2": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.6.0.tgz", - "integrity": "sha512-EWUGAhv6SphezurlfI2Fpt0uJEWLmirrtQR7SkbTHFC+4/mJBrPiSzHESHKAWKG7ALVD6xaG/NBjjd1DGJGQQQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.7.0.tgz", + "integrity": "sha512-c45jA3Jc1X8yJKzrWu1GpplBKGwv/wIV6ITZTlCSY7npF2YfJR+6nMP5e+NTQhUeJPSyOQAbGDCGEHbAl8HN9w==", "dependencies": { "denque": "^2.1.0", "generate-function": "^2.3.1", @@ -12230,9 +12230,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "mysql2": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.6.0.tgz", - "integrity": "sha512-EWUGAhv6SphezurlfI2Fpt0uJEWLmirrtQR7SkbTHFC+4/mJBrPiSzHESHKAWKG7ALVD6xaG/NBjjd1DGJGQQQ==", + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.7.0.tgz", + "integrity": "sha512-c45jA3Jc1X8yJKzrWu1GpplBKGwv/wIV6ITZTlCSY7npF2YfJR+6nMP5e+NTQhUeJPSyOQAbGDCGEHbAl8HN9w==", "requires": { "denque": "^2.1.0", "generate-function": "^2.3.1", diff --git a/backend/package.json b/backend/package.json index 0c1d3cc4a..cd1255392 100644 --- a/backend/package.json +++ b/backend/package.json @@ -35,7 +35,8 @@ "lint": "./node_modules/.bin/eslint . --ext .ts", "lint:fix": "./node_modules/.bin/eslint . --ext .ts --fix", "prettier": "./node_modules/.bin/prettier --write \"src/**/*.{js,ts}\"", - "rust-build": "cd rust-gbt && npm run build-release" + "rust-clean": "cd rust-gbt && rm -f *.node index.d.ts index.js && rm -rf target && cd ../", + "rust-build": "npm run rust-clean && cd rust-gbt && npm run build-release" }, "dependencies": { "@babel/core": "^7.23.2", @@ -46,7 +47,7 @@ "crypto-js": "~4.2.0", "express": "~4.18.2", "maxmind": "~4.3.11", - "mysql2": "~3.6.0", + "mysql2": "~3.7.0", "rust-gbt": "file:./rust-gbt", "redis": "^4.6.6", "socks-proxy-agent": "~7.0.0", diff --git a/backend/rust-gbt/index.d.ts b/backend/rust-gbt/index.d.ts index 2bd8a620a..d1cb85b92 100644 --- a/backend/rust-gbt/index.d.ts +++ b/backend/rust-gbt/index.d.ts @@ -45,5 +45,6 @@ export class GbtResult { blockWeights: Array clusters: Array> rates: Array> - constructor(blocks: Array>, blockWeights: Array, clusters: Array>, rates: Array>) + overflow: Array + constructor(blocks: Array>, blockWeights: Array, clusters: Array>, rates: Array>, overflow: Array) } diff --git a/backend/rust-gbt/src/gbt.rs b/backend/rust-gbt/src/gbt.rs index fb28dc299..38bf826a6 100644 --- a/backend/rust-gbt/src/gbt.rs +++ b/backend/rust-gbt/src/gbt.rs @@ -60,6 +60,7 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap, accelerations: &[ThreadAccelerat indexed_accelerations[acceleration.uid as usize] = Some(acceleration); } + info!("Initializing working vecs with uid capacity for {}", max_uid + 1); let mempool_len = mempool.len(); let mut audit_pool: AuditPool = Vec::with_capacity(max_uid + 1); audit_pool.resize(max_uid + 1, None); @@ -127,74 +128,75 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap, accelerations: &[ThreadAccelerat let next_from_stack = next_valid_from_stack(&mut mempool_stack, &audit_pool); let next_from_queue = next_valid_from_queue(&mut modified, &audit_pool); if next_from_stack.is_none() && next_from_queue.is_none() { - continue; - } - let (next_tx, from_stack) = match (next_from_stack, next_from_queue) { - (Some(stack_tx), Some(queue_tx)) => match queue_tx.cmp(stack_tx) { - std::cmp::Ordering::Less => (stack_tx, true), - _ => (queue_tx, false), - }, - (Some(stack_tx), None) => (stack_tx, true), - (None, Some(queue_tx)) => (queue_tx, false), - (None, None) => unreachable!(), - }; - - if from_stack { - mempool_stack.pop(); + info!("No transactions left! {:#?} in overflow", overflow.len()); } else { - modified.pop(); - } + let (next_tx, from_stack) = match (next_from_stack, next_from_queue) { + (Some(stack_tx), Some(queue_tx)) => match queue_tx.cmp(stack_tx) { + std::cmp::Ordering::Less => (stack_tx, true), + _ => (queue_tx, false), + }, + (Some(stack_tx), None) => (stack_tx, true), + (None, Some(queue_tx)) => (queue_tx, false), + (None, None) => unreachable!(), + }; - if blocks.len() < (MAX_BLOCKS - 1) - && ((block_weight + (4 * next_tx.ancestor_sigop_adjusted_vsize()) - >= MAX_BLOCK_WEIGHT_UNITS) - || (block_sigops + next_tx.ancestor_sigops() > BLOCK_SIGOPS)) - { - // hold this package in an overflow list while we check for smaller options - overflow.push(next_tx.uid); - failures += 1; - } else { - let mut package: Vec<(u32, u32, usize)> = Vec::new(); - let mut cluster: Vec = Vec::new(); - let is_cluster: bool = !next_tx.ancestors.is_empty(); - for ancestor_id in &next_tx.ancestors { - if let Some(Some(ancestor)) = audit_pool.get(*ancestor_id as usize) { - package.push((*ancestor_id, ancestor.order(), ancestor.ancestors.len())); - } - } - package.sort_unstable_by(|a, b| -> Ordering { - if a.2 != b.2 { - // order by ascending ancestor count - a.2.cmp(&b.2) - } else if a.1 != b.1 { - // tie-break by ascending partial txid - a.1.cmp(&b.1) - } else { - // tie-break partial txid collisions by ascending uid - a.0.cmp(&b.0) - } - }); - package.push((next_tx.uid, next_tx.order(), next_tx.ancestors.len())); - - let cluster_rate = next_tx.cluster_rate(); - - for (txid, _, _) in &package { - cluster.push(*txid); - if let Some(Some(tx)) = audit_pool.get_mut(*txid as usize) { - tx.used = true; - tx.set_dirty_if_different(cluster_rate); - transactions.push(tx.uid); - block_weight += tx.weight; - block_sigops += tx.sigops; - } - update_descendants(*txid, &mut audit_pool, &mut modified, cluster_rate); + if from_stack { + mempool_stack.pop(); + } else { + modified.pop(); } - if is_cluster { - clusters.push(cluster); - } + if blocks.len() < (MAX_BLOCKS - 1) + && ((block_weight + (4 * next_tx.ancestor_sigop_adjusted_vsize()) + >= MAX_BLOCK_WEIGHT_UNITS) + || (block_sigops + next_tx.ancestor_sigops() > BLOCK_SIGOPS)) + { + // hold this package in an overflow list while we check for smaller options + overflow.push(next_tx.uid); + failures += 1; + } else { + let mut package: Vec<(u32, u32, usize)> = Vec::new(); + let mut cluster: Vec = Vec::new(); + let is_cluster: bool = !next_tx.ancestors.is_empty(); + for ancestor_id in &next_tx.ancestors { + if let Some(Some(ancestor)) = audit_pool.get(*ancestor_id as usize) { + package.push((*ancestor_id, ancestor.order(), ancestor.ancestors.len())); + } + } + package.sort_unstable_by(|a, b| -> Ordering { + if a.2 != b.2 { + // order by ascending ancestor count + a.2.cmp(&b.2) + } else if a.1 != b.1 { + // tie-break by ascending partial txid + a.1.cmp(&b.1) + } else { + // tie-break partial txid collisions by ascending uid + a.0.cmp(&b.0) + } + }); + package.push((next_tx.uid, next_tx.order(), next_tx.ancestors.len())); - failures = 0; + let cluster_rate = next_tx.cluster_rate(); + + for (txid, _, _) in &package { + cluster.push(*txid); + if let Some(Some(tx)) = audit_pool.get_mut(*txid as usize) { + tx.used = true; + tx.set_dirty_if_different(cluster_rate); + transactions.push(tx.uid); + block_weight += tx.weight; + block_sigops += tx.sigops; + } + update_descendants(*txid, &mut audit_pool, &mut modified, cluster_rate); + } + + if is_cluster { + clusters.push(cluster); + } + + failures = 0; + } } // this block is full @@ -203,10 +205,14 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap, accelerations: &[ThreadAccelerat let queue_is_empty = mempool_stack.is_empty() && modified.is_empty(); if (exceeded_package_tries || queue_is_empty) && blocks.len() < (MAX_BLOCKS - 1) { // finalize this block - if !transactions.is_empty() { - blocks.push(transactions); - block_weights.push(block_weight); + if transactions.is_empty() { + info!("trying to push an empty block! breaking loop! mempool {:#?} | modified {:#?} | overflow {:#?}", mempool_stack.len(), modified.len(), overflow.len()); + break; } + + blocks.push(transactions); + block_weights.push(block_weight); + // reset for the next block transactions = Vec::with_capacity(initial_txes_per_block); block_weight = BLOCK_RESERVED_WEIGHT; @@ -265,6 +271,7 @@ pub fn gbt(mempool: &mut ThreadTransactionsMap, accelerations: &[ThreadAccelerat block_weights, clusters, rates, + overflow, } } diff --git a/backend/rust-gbt/src/lib.rs b/backend/rust-gbt/src/lib.rs index 53db0ba21..edc9714ee 100644 --- a/backend/rust-gbt/src/lib.rs +++ b/backend/rust-gbt/src/lib.rs @@ -133,6 +133,7 @@ pub struct GbtResult { pub block_weights: Vec, pub clusters: Vec>, pub rates: Vec>, // Tuples not supported. u32 fits inside f64 + pub overflow: Vec, } /// All on another thread, this runs an arbitrary task in between diff --git a/backend/src/api/fee-api.ts b/backend/src/api/fee-api.ts index 0cab5a295..24fd25a4b 100644 --- a/backend/src/api/fee-api.ts +++ b/backend/src/api/fee-api.ts @@ -39,15 +39,25 @@ class FeeApi { 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; + let fastestFee = Math.max(minimumFee, firstMedianFee); + let halfHourFee = Math.max(minimumFee, secondMedianFee); + let hourFee = Math.max(minimumFee, thirdMedianFee); + const economyFee = Math.max(minimumFee, Math.min(2 * minimumFee, thirdMedianFee)); + + // ensure recommendations always increase w/ priority + fastestFee = Math.max(fastestFee, halfHourFee, hourFee, economyFee); + halfHourFee = Math.max(halfHourFee, hourFee, economyFee); + hourFee = Math.max(hourFee, economyFee); + // explicitly enforce a minimum of ceil(mempoolminfee) on all recommendations. // simply rounding up recommended rates is insufficient, as the purging rate // can exceed the median rate of projected blocks in some extreme scenarios // (see https://bitcoin.stackexchange.com/a/120024) return { - 'fastestFee': Math.max(minimumFee, firstMedianFee), - 'halfHourFee': Math.max(minimumFee, secondMedianFee), - 'hourFee': Math.max(minimumFee, thirdMedianFee), - 'economyFee': Math.max(minimumFee, Math.min(2 * minimumFee, thirdMedianFee)), + 'fastestFee': fastestFee, + 'halfHourFee': halfHourFee, + 'hourFee': hourFee, + 'economyFee': economyFee, 'minimumFee': minimumFee, }; } diff --git a/backend/src/api/mempool-blocks.ts b/backend/src/api/mempool-blocks.ts index a7f00f6e8..0ca550f4c 100644 --- a/backend/src/api/mempool-blocks.ts +++ b/backend/src/api/mempool-blocks.ts @@ -368,12 +368,15 @@ class MempoolBlocks { // run the block construction algorithm in a separate thread, and wait for a result const rustGbt = saveResults ? this.rustGbtGenerator : new GbtGenerator(); try { - const { blocks, blockWeights, rates, clusters } = this.convertNapiResultTxids( + const { blocks, blockWeights, rates, clusters, overflow } = this.convertNapiResultTxids( await rustGbt.make(Object.values(newMempool) as RustThreadTransaction[], convertedAccelerations as RustThreadAcceleration[], this.nextUid), ); if (saveResults) { this.rustInitialized = true; } + const mempoolSize = Object.keys(newMempool).length; + const resultMempoolSize = blocks.reduce((total, block) => total + block.length, 0) + overflow.length; + logger.debug(`RUST updateBlockTemplates returned ${resultMempoolSize} txs out of ${mempoolSize} in the mempool, ${overflow.length} were unmineable`); const processed = this.processBlockTemplates(newMempool, blocks, blockWeights, rates, clusters, accelerations, accelerationPool, saveResults); logger.debug(`RUST makeBlockTemplates completed in ${(Date.now() - start)/1000} seconds`); return processed; @@ -424,7 +427,7 @@ class MempoolBlocks { // run the block construction algorithm in a separate thread, and wait for a result try { - const { blocks, blockWeights, rates, clusters } = this.convertNapiResultTxids( + const { blocks, blockWeights, rates, clusters, overflow } = this.convertNapiResultTxids( await this.rustGbtGenerator.update( added as RustThreadTransaction[], removedUids, @@ -432,9 +435,10 @@ class MempoolBlocks { this.nextUid, ), ); - const resultMempoolSize = blocks.reduce((total, block) => total + block.length, 0); + const resultMempoolSize = blocks.reduce((total, block) => total + block.length, 0) + overflow.length; + logger.debug(`RUST updateBlockTemplates returned ${resultMempoolSize} txs out of ${mempoolSize} in the mempool, ${overflow.length} were unmineable`); if (mempoolSize !== resultMempoolSize) { - throw new Error('GBT returned wrong number of transactions, cache is probably out of sync'); + throw new Error('GBT returned wrong number of transactions , cache is probably out of sync'); } else { const processed = this.processBlockTemplates(newMempool, blocks, blockWeights, rates, clusters, accelerations, accelerationPool, true); this.removeUids(removedUids); @@ -658,8 +662,8 @@ class MempoolBlocks { return { blocks: convertedBlocks, rates: convertedRates, clusters: convertedClusters } as { blocks: string[][], rates: { [root: string]: number }, clusters: { [root: string]: string[] }}; } - private convertNapiResultTxids({ blocks, blockWeights, rates, clusters }: GbtResult) - : { blocks: string[][], blockWeights: number[], rates: [string, number][], clusters: string[][] } { + private convertNapiResultTxids({ blocks, blockWeights, rates, clusters, overflow }: GbtResult) + : { blocks: string[][], blockWeights: number[], rates: [string, number][], clusters: string[][], overflow: string[] } { const convertedBlocks: string[][] = blocks.map(block => block.map(uid => { const txid = this.uidMap.get(uid); if (txid !== undefined) { @@ -677,7 +681,15 @@ class MempoolBlocks { for (const cluster of clusters) { convertedClusters.push(cluster.map(uid => this.uidMap.get(uid)) as string[]); } - return { blocks: convertedBlocks, blockWeights, rates: convertedRates, clusters: convertedClusters }; + const convertedOverflow: string[] = overflow.map(uid => { + const txid = this.uidMap.get(uid); + if (txid !== undefined) { + return txid; + } else { + throw new Error('GBT returned an unmineable transaction with unknown uid'); + } + }); + return { blocks: convertedBlocks, blockWeights, rates: convertedRates, clusters: convertedClusters, overflow: convertedOverflow }; } } diff --git a/backend/src/api/tx-selection-worker.ts b/backend/src/api/tx-selection-worker.ts index 0acc2f65e..8ac7328fe 100644 --- a/backend/src/api/tx-selection-worker.ts +++ b/backend/src/api/tx-selection-worker.ts @@ -173,10 +173,13 @@ function makeBlockTemplates(mempool: Map) // this block is full const exceededPackageTries = failures > 1000 && blockWeight > (config.MEMPOOL.BLOCK_WEIGHT_UNITS - 4000); const queueEmpty = top >= mempoolArray.length && modified.isEmpty(); + if ((exceededPackageTries || queueEmpty) && blocks.length < 7) { // construct this block if (transactions.length) { blocks.push(transactions.map(t => t.uid)); + } else { + break; } // reset for the next block transactions = []; diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 34d4682d2..937d4a7c5 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -968,7 +968,7 @@ class WebsocketHandler { if (client['track-tx']) { numTxSubs++; } - if (client['track-mempool-block'] >= 0) { + if (client['track-mempool-block'] != null && client['track-mempool-block'] >= 0) { numProjectedSubs++; } if (client['track-rbf']) { diff --git a/backend/src/tasks/price-feeds/coinbase-api.ts b/backend/src/tasks/price-feeds/coinbase-api.ts index 424ac8867..d2c6d063a 100644 --- a/backend/src/tasks/price-feeds/coinbase-api.ts +++ b/backend/src/tasks/price-feeds/coinbase-api.ts @@ -5,14 +5,14 @@ class CoinbaseApi implements PriceFeed { public name: string = 'Coinbase'; public currencies: string[] = ['USD', 'EUR', 'GBP']; - public url: string = 'https://api.coinbase.com/v2/prices/spot?currency='; + public url: string = 'https://api.coinbase.com/v2/prices/BTC-{CURRENCY}/spot'; public urlHist: string = 'https://api.exchange.coinbase.com/products/BTC-{CURRENCY}/candles?granularity={GRANULARITY}'; constructor() { } public async $fetchPrice(currency): Promise { - const response = await query(this.url + currency); + const response = await query(this.url.replace('{CURRENCY}', currency)); if (response && response['data'] && response['data']['amount']) { return parseInt(response['data']['amount'], 10); } else { diff --git a/backend/src/tasks/price-updater.ts b/backend/src/tasks/price-updater.ts index fd799fb87..0d5ca5958 100644 --- a/backend/src/tasks/price-updater.ts +++ b/backend/src/tasks/price-updater.ts @@ -23,6 +23,14 @@ export interface PriceHistory { [timestamp: number]: ApiPrice; } +function getMedian(arr: number[]): number { + const sortedArr = arr.slice().sort((a, b) => a - b); + const mid = Math.floor(sortedArr.length / 2); + return sortedArr.length % 2 !== 0 + ? sortedArr[mid] + : (sortedArr[mid - 1] + sortedArr[mid]) / 2; +} + class PriceUpdater { public historyInserted = false; private timeBetweenUpdatesMs = 360_0000 / config.MEMPOOL.PRICE_UPDATES_PER_HOUR; @@ -173,7 +181,7 @@ class PriceUpdater { if (prices.length === 0) { this.latestPrices[currency] = -1; } else { - this.latestPrices[currency] = Math.round((prices.reduce((partialSum, a) => partialSum + a, 0)) / prices.length); + this.latestPrices[currency] = Math.round(getMedian(prices)); } } @@ -300,9 +308,7 @@ class PriceUpdater { if (grouped[time][currency].length === 0) { continue; } - prices[currency] = Math.round((grouped[time][currency].reduce( - (partialSum, a) => partialSum + a, 0) - ) / grouped[time][currency].length); + prices[currency] = Math.round(getMedian(grouped[time][currency])); } await PricesRepository.$savePrices(parseInt(time, 10), prices); ++totalInserted; diff --git a/frontend/package-lock.json b/frontend/package-lock.json index b02ee1c50..59bdac54a 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -59,7 +59,7 @@ "@cypress/schematic": "^2.5.0", "@types/cypress": "^1.1.3", "cypress": "^13.6.0", - "cypress-fail-on-console-error": "~5.0.0", + "cypress-fail-on-console-error": "~5.1.0", "cypress-wait-until": "^2.0.1", "mock-socket": "~9.3.1", "start-server-and-test": "~2.0.0" @@ -4068,9 +4068,9 @@ } }, "node_modules/@sinonjs/fake-timers": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", - "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz", + "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==", "optional": true, "dependencies": { "@sinonjs/commons": "^3.0.0" @@ -6242,17 +6242,18 @@ "optional": true }, "node_modules/chai": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", - "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.0.tgz", + "integrity": "sha512-x9cHNq1uvkCdU+5xTkNh5WtgD4e4yDFCsp9jVc7N7qVeKeftv3gO/ZrviX5d+3ZfxdYnZXZYujjRInu1RogU6A==", "optional": true, "dependencies": { "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "type-detect": "^4.0.8" }, "engines": { "node": ">=4" @@ -6277,10 +6278,13 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" }, "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", "optional": true, + "dependencies": { + "get-func-name": "^2.0.2" + }, "engines": { "node": "*" } @@ -7137,13 +7141,13 @@ } }, "node_modules/cypress-fail-on-console-error": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cypress-fail-on-console-error/-/cypress-fail-on-console-error-5.0.0.tgz", - "integrity": "sha512-xui/aSu8rmExZjZNgId3iX0MsGZih6ZoFH+54vNHrK3HaqIZZX5hUuNhAcmfSoM1rIDc2DeITeVaMn/hiQ9IWQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cypress-fail-on-console-error/-/cypress-fail-on-console-error-5.1.0.tgz", + "integrity": "sha512-u/AXLE9obLd9KcGHkGJluJVZeOj1EEOFOs0URxxca4FrftUDJQ3u+IoNfjRUjsrBKmJxgM4vKd0G10D+ZT1uIA==", "optional": true, "dependencies": { - "chai": "^4.3.4", - "sinon": "^15.0.0", + "chai": "^4.3.10", + "sinon": "^17.0.0", "sinon-chai": "^3.7.0", "type-detect": "^4.0.8" } @@ -7403,15 +7407,15 @@ "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=" }, "node_modules/deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "optional": true, "dependencies": { "type-detect": "^4.0.0" }, "engines": { - "node": ">=0.12" + "node": ">=6" } }, "node_modules/deep-equal": { @@ -9268,9 +9272,9 @@ "devOptional": true }, "node_modules/follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "funding": [ { "type": "individual", @@ -11759,6 +11763,15 @@ "node": ">=8.0" } }, + "node_modules/loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "optional": true, + "dependencies": { + "get-func-name": "^2.0.1" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -12537,9 +12550,9 @@ } }, "node_modules/nise": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", - "integrity": "sha512-8+Ib8rRJ4L0o3kfmyVCL7gzrohyDe0cMFTBa2d364yIrEGMEoetznKJx899YxjybU6bL9SQkYPSBBs1gyYs8Xg==", + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.5.tgz", + "integrity": "sha512-VJuPIfUFaXNRzETTQEEItTOP8Y171ijr+JLq42wHes3DiryR8vT+1TXQW/Rx8JNUhyYYWyIvjXTU6dOhJcs9Nw==", "optional": true, "dependencies": { "@sinonjs/commons": "^2.0.0", @@ -12558,6 +12571,24 @@ "type-detect": "4.0.8" } }, + "node_modules/nise/node_modules/@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "optional": true, + "dependencies": { + "@sinonjs/commons": "^3.0.0" + } + }, + "node_modules/nise/node_modules/@sinonjs/fake-timers/node_modules/@sinonjs/commons": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "optional": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, "node_modules/nise/node_modules/isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -14842,16 +14873,16 @@ ] }, "node_modules/sinon": { - "version": "15.2.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.2.0.tgz", - "integrity": "sha512-nPS85arNqwBXaIsFCkolHjGIkFo+Oxu9vbgmBJizLAhqe6P2o3Qmj3KCUoRkfhHtvgDhZdWD3risLHAUJ8npjw==", + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", + "integrity": "sha512-wmwE19Lie0MLT+ZYNpDymasPHUKTaZHUH/pKEubRXIzySv9Atnlw+BUMGCzWgV7b7wO+Hw6f1TEOr0IUnmU8/g==", "optional": true, "dependencies": { "@sinonjs/commons": "^3.0.0", - "@sinonjs/fake-timers": "^10.3.0", + "@sinonjs/fake-timers": "^11.2.2", "@sinonjs/samsam": "^8.0.0", "diff": "^5.1.0", - "nise": "^5.1.4", + "nise": "^5.1.5", "supports-color": "^7.2.0" }, "funding": { @@ -19882,9 +19913,9 @@ } }, "@sinonjs/fake-timers": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", - "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz", + "integrity": "sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==", "optional": true, "requires": { "@sinonjs/commons": "^3.0.0" @@ -21594,17 +21625,18 @@ "optional": true }, "chai": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", - "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.0.tgz", + "integrity": "sha512-x9cHNq1uvkCdU+5xTkNh5WtgD4e4yDFCsp9jVc7N7qVeKeftv3gO/ZrviX5d+3ZfxdYnZXZYujjRInu1RogU6A==", "optional": true, "requires": { "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", + "check-error": "^1.0.3", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "type-detect": "^4.0.8" } }, "chalk": { @@ -21623,10 +21655,13 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" }, "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "optional": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz", + "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==", + "optional": true, + "requires": { + "get-func-name": "^2.0.2" + } }, "check-more-types": { "version": "2.24.0", @@ -22403,13 +22438,13 @@ } }, "cypress-fail-on-console-error": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/cypress-fail-on-console-error/-/cypress-fail-on-console-error-5.0.0.tgz", - "integrity": "sha512-xui/aSu8rmExZjZNgId3iX0MsGZih6ZoFH+54vNHrK3HaqIZZX5hUuNhAcmfSoM1rIDc2DeITeVaMn/hiQ9IWQ==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cypress-fail-on-console-error/-/cypress-fail-on-console-error-5.1.0.tgz", + "integrity": "sha512-u/AXLE9obLd9KcGHkGJluJVZeOj1EEOFOs0URxxca4FrftUDJQ3u+IoNfjRUjsrBKmJxgM4vKd0G10D+ZT1uIA==", "optional": true, "requires": { - "chai": "^4.3.4", - "sinon": "^15.0.0", + "chai": "^4.3.10", + "sinon": "^17.0.0", "sinon-chai": "^3.7.0", "type-detect": "^4.0.8" } @@ -22490,9 +22525,9 @@ "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=" }, "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", "optional": true, "requires": { "type-detect": "^4.0.0" @@ -23957,9 +23992,9 @@ "devOptional": true }, "follow-redirects": { - "version": "1.15.3", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==" + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==" }, "foreach": { "version": "2.0.5", @@ -25754,6 +25789,15 @@ "streamroller": "^3.0.2" } }, + "loupe": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz", + "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==", + "optional": true, + "requires": { + "get-func-name": "^2.0.1" + } + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -26361,9 +26405,9 @@ } }, "nise": { - "version": "5.1.4", - "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", - "integrity": "sha512-8+Ib8rRJ4L0o3kfmyVCL7gzrohyDe0cMFTBa2d364yIrEGMEoetznKJx899YxjybU6bL9SQkYPSBBs1gyYs8Xg==", + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.5.tgz", + "integrity": "sha512-VJuPIfUFaXNRzETTQEEItTOP8Y171ijr+JLq42wHes3DiryR8vT+1TXQW/Rx8JNUhyYYWyIvjXTU6dOhJcs9Nw==", "optional": true, "requires": { "@sinonjs/commons": "^2.0.0", @@ -26382,6 +26426,26 @@ "type-detect": "4.0.8" } }, + "@sinonjs/fake-timers": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-10.3.0.tgz", + "integrity": "sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==", + "optional": true, + "requires": { + "@sinonjs/commons": "^3.0.0" + }, + "dependencies": { + "@sinonjs/commons": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", + "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "optional": true, + "requires": { + "type-detect": "4.0.8" + } + } + } + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -28036,16 +28100,16 @@ "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==" }, "sinon": { - "version": "15.2.0", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-15.2.0.tgz", - "integrity": "sha512-nPS85arNqwBXaIsFCkolHjGIkFo+Oxu9vbgmBJizLAhqe6P2o3Qmj3KCUoRkfhHtvgDhZdWD3risLHAUJ8npjw==", + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-17.0.1.tgz", + "integrity": "sha512-wmwE19Lie0MLT+ZYNpDymasPHUKTaZHUH/pKEubRXIzySv9Atnlw+BUMGCzWgV7b7wO+Hw6f1TEOr0IUnmU8/g==", "optional": true, "requires": { "@sinonjs/commons": "^3.0.0", - "@sinonjs/fake-timers": "^10.3.0", + "@sinonjs/fake-timers": "^11.2.2", "@sinonjs/samsam": "^8.0.0", "diff": "^5.1.0", - "nise": "^5.1.4", + "nise": "^5.1.5", "supports-color": "^7.2.0" }, "dependencies": { diff --git a/frontend/package.json b/frontend/package.json index a4a4ac462..8dbcbcf3e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -111,7 +111,7 @@ "@cypress/schematic": "^2.5.0", "@types/cypress": "^1.1.3", "cypress": "^13.6.0", - "cypress-fail-on-console-error": "~5.0.0", + "cypress-fail-on-console-error": "~5.1.0", "cypress-wait-until": "^2.0.1", "mock-socket": "~9.3.1", "start-server-and-test": "~2.0.0" diff --git a/frontend/src/app/components/block-overview-graph/block-scene.ts b/frontend/src/app/components/block-overview-graph/block-scene.ts index cb589527d..adcf736fc 100644 --- a/frontend/src/app/components/block-overview-graph/block-scene.ts +++ b/frontend/src/app/components/block-overview-graph/block-scene.ts @@ -11,7 +11,7 @@ export default class BlockScene { getColor: ((tx: TxView) => Color) = defaultColorFunction; orientation: string; flip: boolean; - animationDuration: number = 1000; + animationDuration: number = 900; configAnimationOffset: number | null; animationOffset: number; highlightingEnabled: boolean; diff --git a/frontend/src/app/components/block/block.component.html b/frontend/src/app/components/block/block.component.html index e908d5b24..b34b39c8c 100644 --- a/frontend/src/app/components/block/block.component.html +++ b/frontend/src/app/components/block/block.component.html @@ -59,7 +59,7 @@ - Health + Health  state === 2)) - ) - .pipe(switchMap(() => this.stateService.mempoolBlockTransactions$)) - .subscribe((transactionsStripped) => { + this.stateService.mempoolBlockTransactions$, + this.stateService.mempoolBlockDelta$, + ).pipe( + concatMap(update => { + const now = Date.now(); + const timeSinceLastEvent = now - this.lastEventTime; + this.lastEventTime = Math.max(now, this.lastEventTime + this.rateLimit); + + const subId = this.subId; + + // If time since last event is less than X seconds, delay this event + if (timeSinceLastEvent < this.rateLimit) { + return timer(this.rateLimit - timeSinceLastEvent).pipe( + // Emit the event after the timer + map(() => ({ update, subId })) + ); + } else { + // If enough time has passed, emit the event immediately + return of({ update, subId }); + } + }) + ).subscribe(({ update, subId }) => { + // discard stale updates after a block transition + if (subId !== this.subId) { + return; + } + // process update + if (update['added']) { + // delta + this.updateBlock(update as MempoolBlockDelta); + } else { + const transactionsStripped = update as TransactionStripped[]; + // new transactions if (this.firstLoad) { this.replaceBlock(transactionsStripped); } else { @@ -94,14 +124,13 @@ export class MempoolBlockOverviewComponent implements OnInit, OnDestroy, OnChang added }); } - }); - this.deltaSub = this.stateService.mempoolBlockDelta$.subscribe((delta) => { - this.updateBlock(delta); + } }); } ngOnChanges(changes): void { if (changes.index) { + this.subId++; this.firstLoad = true; if (this.blockGraph) { this.blockGraph.clear(changes.index.currentValue > changes.index.previousValue ? this.chainDirection : this.poolDirection); @@ -113,7 +142,6 @@ export class MempoolBlockOverviewComponent implements OnInit, OnDestroy, OnChang ngOnDestroy(): void { this.blockSub.unsubscribe(); - this.deltaSub.unsubscribe(); this.timeLtrSubscription.unsubscribe(); this.websocketService.stopTrackMempoolBlock(); } diff --git a/frontend/src/app/components/mempool-block/mempool-block.component.ts b/frontend/src/app/components/mempool-block/mempool-block.component.ts index 197b07247..89fb97dad 100644 --- a/frontend/src/app/components/mempool-block/mempool-block.component.ts +++ b/frontend/src/app/components/mempool-block/mempool-block.component.ts @@ -75,6 +75,7 @@ export class MempoolBlockComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this.stateService.markBlock$.next({}); + this.websocketService.stopTrackMempoolBlock(); } getOrdinal(mempoolBlock: MempoolBlock): string { diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 313d6879c..8ac4cf919 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -299,7 +299,11 @@ - Adjusted vsize + Adjusted vsize + + + + @@ -321,7 +325,11 @@ - Sigops + Sigops + + + + diff --git a/frontend/src/app/docs/api-docs/api-docs-data.ts b/frontend/src/app/docs/api-docs/api-docs-data.ts index 97be0c2b1..86a63e513 100644 --- a/frontend/src/app/docs/api-docs/api-docs-data.ts +++ b/frontend/src/app/docs/api-docs/api-docs-data.ts @@ -209,6 +209,114 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "general", + httpRequestMethod: "GET", + fragment: "get-price", + title: "GET Price", + description: { + default: "Returns bitcoin latest price denominated in main currencies." + }, + urlString: "/v1/prices", + showConditions: [""], + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + commonJS: ``, + esModule: ``, + curl: `/api/v1/prices`, + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [], + response: `{ + time: 1703252411, + USD: 43753, + EUR: 40545, + GBP: 37528, + CAD: 58123, + CHF: 37438, + AUD: 64499, + JPY: 6218915 +}` + }, + codeSampleTestnet: emptyCodeSample, + codeSampleSignet: emptyCodeSample, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, + { + type: "endpoint", + category: "general", + httpRequestMethod: "GET", + fragment: "get-historical-price", + title: "GET Historical Price", + description: { + default: "Returns bitcoin historical price denominated in main currencies." + }, + urlString: "/v1/historical-price", + showConditions: [""], + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + commonJS: ``, + esModule: ``, + curl: `/api/v1/historical-price`, + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [], + response: `{ + prices: [ + { + time: 1703692800, + USD: 42972, + EUR: 39590, + GBP: 36803, + CAD: 56883, + CHF: 36486, + AUD: 63006, + JPY: 6124530 + }, + ... + { + time: 1279497600, + USD: 0.08584, + EUR: -1, + GBP: -1, + CAD: -1, + CHF: -1, + AUD: -1, + JPY: -1 + } + ], + exchangeRates: { + USDEUR: 0.92, + USDGBP: 0.86, + USDCAD: 1.32, + USDCHF: 0.85, + USDAUD: 1.47, + USDJPY: 142.52 + } +} +` + }, + codeSampleTestnet: emptyCodeSample, + codeSampleSignet: emptyCodeSample, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, { type: "endpoint", category: "general", @@ -1409,20 +1517,20 @@ export const restApiDocsData = [ ]` }, codeSampleSignet: { - esModule: [`1wiz18xYmhRX6xStj2b9t1rwWX4GKUgpv`], - commonJS: [`1wiz18xYmhRX6xStj2b9t1rwWX4GKUgpv`], - curl: [`1wiz18xYmhRX6xStj2b9t1rwWX4GKUgpv`], + esModule: [`tb1pu8ysre22dcl6qy5m5w7mjwutw73w4u24slcdh4myq06uhr6q29dqwc3ckt`], + commonJS: [`tb1pu8ysre22dcl6qy5m5w7mjwutw73w4u24slcdh4myq06uhr6q29dqwc3ckt`], + curl: [`tb1pu8ysre22dcl6qy5m5w7mjwutw73w4u24slcdh4myq06uhr6q29dqwc3ckt`], response: `[ { - txid: "e58b47f657b496a083ad9a4fb10c744d5e993028efd9cfba149885334d98bdf5", + txid: "c56a054302df8f8f80c5ac6b86b24ed52bf41d64de640659837c56bc33d10c9e", vout: 0, status: { confirmed: true, - block_height: 698571, - block_hash: "00000000000000000007536c0a664a7d2a01c31569623183eba0768d9a0c163d", - block_time: 1630520708 + block_height: 174923, + block_hash: "000000750e335ff355be2e3754fdada30d107d7d916aef07e2f5d014bec845e5", + block_time: 1703321003 }, - value: 642070789 + value: 546 }, ... ]` @@ -1470,6 +1578,65 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "addresses", + httpRequestMethod: "GET", + fragment: "get-address-validate", + title: "GET Address Validation", + description: { + default: "Returns whether an address is valid or not. Available fields: isvalid (boolean), address (string), scriptPubKey (string), isscript (boolean), iswitness (boolean), witness_version (numeric, optional), and witness_program (string, optional).", + }, + urlString: "/v1/validate-address/:address", + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/validate-address/%{1}`, + commonJS: ``, + esModule: ``, + }, + codeSampleMainnet: { + curl: [`1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY`], + response: `{ + isvalid: true, + address: "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY", + scriptPubKey: "76a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac", + isscript: false, + iswitness: false +}` + }, + codeSampleTestnet: { + curl: [`tb1q4kgratttzjvkxfmgd95z54qcq7y6hekdm3w56u`], + response: `{ + isvalid: true, + address: "tb1q4kgratttzjvkxfmgd95z54qcq7y6hekdm3w56u", + scriptPubKey: "0014ad903ead6b149963276869682a54180789abe6cd", + isscript: false, + iswitness: true, + witness_version: 0, + witness_program: "ad903ead6b149963276869682a54180789abe6cd" +}` + }, + codeSampleSignet: { + curl: [`tb1pu8ysre22dcl6qy5m5w7mjwutw73w4u24slcdh4myq06uhr6q29dqwc3ckt`], + response: `{ + isvalid: true, + address: "tb1pu8ysre22dcl6qy5m5w7mjwutw73w4u24slcdh4myq06uhr6q29dqwc3ckt", + scriptPubKey: "5120e1c901e54a6e3fa0129ba3bdb93b8b77a2eaf15587f0dbd76403f5cb8f40515a", + isscript: true, + iswitness: true, + witness_version: 1, + witness_program: "e1c901e54a6e3fa0129ba3bdb93b8b77a2eaf15587f0dbd76403f5cb8f40515a" +}` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, { type: "category", category: "assets", @@ -2109,6 +2276,61 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "blocks", + httpRequestMethod: "GET", + fragment: "get-block-timestamp", + title: "GET Block Timestamp", + description: { + default: "Returns the height and the hash of the block closest to the given :timestamp." + }, + urlString: "/v1/mining/blocks/timestamp/:timestamp", + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/mining/blocks/timestamp/%{1}`, + commonJS: ``, + esModule: `` + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: ['1672531200'], + response: `{ + height: 769786, + hash: "000000000000000000017f6405c2382de84944eb21be9cec0379a735813f137b", + timestamp: "2022-12-31T23:30:31.000Z" +}` + }, + codeSampleTestnet: { + esModule: [], + commonJS: [], + curl: ['1672531200'], + response: `{ + height: 2413838, + hash: "00000000000000082888e2353ea4baaea04d2e0e88f2ee054ad2bbcc1d6a5469", + timestamp: "2022-12-31T23:57:26.000Z" +}` + }, + codeSampleSignet: { + esModule: [], + commonJS: [], + curl: ['1672531200'], + response: `{ + height: 123713, + hash: "0000010c6df8ffe1684ab9d7cfac69836a4538c057fab4571b809120fe486c96", + timestamp: "2022-12-31T23:55:56.000Z" +}` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, { type: "endpoint", category: "blocks", @@ -4042,6 +4264,101 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "mining", + httpRequestMethod: "GET", + fragment: "get-difficulty-adjustments", + title: "GET Difficulty Adjustments", + description: { + default: "

Returns the record of difficulty adjustments over the specified trailing :interval:

  • Block timestamp
  • Block height
  • Difficulty
  • Difficulty change

If no time interval is specified, all available data is returned." + }, + urlString: "/v1/mining/difficulty-adjustments/[:interval]", + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/mining/difficulty-adjustments/1m`, + commonJS: ``, + esModule: `` + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [], + response: `[ + [ + 1703311464, + 822528, + 72006146478567.1, + 1.06983 + ], + [ + 1702180644, + 820512, + 67305906902031.39, + 0.990408 + ], + [ + 1700957763, + 818496, + 67957790298897.88, + 1.0507 + ] +]` + }, + codeSampleTestnet: { + esModule: [], + commonJS: [], + curl: [], + response: `[ + [ + 1703429523, + 2544008, + 105074715.9955905, + 105075000 + ], + [ + 1703426009, + 2544005, + 1, + 0 + ], + [ + 1703422944, + 2544000, + 105074715.9955905, + 105075000 + ], + ... +]` + }, + codeSampleSignet: { + esModule: [], + commonJS: [], + curl: [], + response: `[ + [ + 1702402252, + 173376, + 0.002967416960321784, + 1.01893 + ], + [ + 1701214807, + 171360, + 0.002912289751655253, + 0.9652 + ] +]` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, { type: "endpoint", category: "mining", @@ -4559,6 +4876,407 @@ export const restApiDocsData = [ }, ... ] +}` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, + { + type: "endpoint", + category: "mining", + httpRequestMethod: "GET", + fragment: "get-block-predictions", + title: "GET Block Predictions", + description: { + default: "

Returns average block health in the specified :timePeriod, ordered oldest to newest. :timePeriod can be any of the following: " + miningTimeIntervals + ".

For 24h and 3d time periods, every block is included and figures are exact (not averages). For the 1w time period, figures may be averages depending on how fast blocks were found around a particular timestamp. For other time periods, figures are averages.

" + }, + urlString: ["/v1/mining/blocks/predictions/:timePeriod"], + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/mining/blocks/predictions/%{1}`, + commonJS: ``, + esModule: `` + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [`3y`], + response: `[ + [ + 1687247274, + 777625, + 100 + ], + [ + 1687066238, + 788621, + 99.85 + ], + [ + 1687263518, + 795182, + 99.46 + ], + [ + 1687312271, + 795260, + 100 + ], + ... +]` + }, + codeSampleTestnet: { + esModule: [], + commonJS: [], + curl: [`3y`], + response: `[ + [ + 1687246773, + 2429248, + 100 + ], + [ + 1687285500, + 2438380, + 100 + ], + [ + 1687342820, + 2438467, + 100 + ], + [ + 1687372143, + 2438522, + 100 + ], + ... +]` + }, + codeSampleSignet: { + esModule: [], + commonJS: [], + curl: [`3y`], + response: `[ + [ + 1687246696, + 129639, + 0 + ], + [ + 1687303289, + 148191, + 0 + ], + [ + 1687315093, + 148218, + 0 + ], + [ + 1687368211, + 148312, + 0 + ], + ... +]` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, + { + type: "endpoint", + category: "mining", + httpRequestMethod: "GET", + fragment: "get-block-audit-score", + title: "GET Block Audit Score", + description: { + default: "Returns the block audit score for the specified :blockHash. Available fields: hash, matchRate, expectedFees, and expectedWeight." + }, + urlString: ["/v1/mining/blocks/audit/score/:blockHash"], + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/mining/blocks/audit/score/%{1}`, + commonJS: ``, + esModule: `` + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [`000000000000000000032535698c5b0c48283b792cf86c1c6e36ff84464de785`], + response: `{ + hash: "000000000000000000032535698c5b0c48283b792cf86c1c6e36ff84464de785", + matchRate: 99.66, + expectedFees: 12090955, + expectedWeight: 3991988 +}` + }, + codeSampleTestnet: { + esModule: [], + commonJS: [], + curl: [`000000000000025a66f30a181e438b9f65ef33cec3014b7a4ff4c7578289cd6e`], + response: `{ + hash: "000000000000025a66f30a181e438b9f65ef33cec3014b7a4ff4c7578289cd6e", + matchRate: 100, + expectedFees: 579169, + expectedWeight: 12997 +}` + }, + codeSampleSignet: { + esModule: [], + commonJS: [], + curl: [`000000c1491d7d4229d4bf07e0dcaa7e396767b45be388e1174c7439a9490121`], + response: `{ + hash: "000000c1491d7d4229d4bf07e0dcaa7e396767b45be388e1174c7439a9490121", + matchRate: 100, + expectedFees: 80520, + expectedWeight: 16487 +}` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, + { + type: "endpoint", + category: "mining", + httpRequestMethod: "GET", + fragment: "get-blocks-audit-scores", + title: "GET Blocks Audit Scores", + description: { + default: "Returns blocks audit score for the past 16 blocks. If :startHeight is specified, the past 15 blocks before (and including) :startHeight are returned. Available fields: hash, matchRate, expectedFees, and expectedWeight." + }, + urlString: ["/v1/mining/blocks/audit/scores/:startHeight"], + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/mining/blocks/audit/scores/%{1}`, + commonJS: ``, + esModule: `` + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [`820000`], + response: `[ + { + hash: "000000000000000000034cd3689507da0386d3d1790dd56f2e6945e650e02c74", + matchRate: 100, + expectedFees: 225828975, + expectedWeight: 3991756 + }, + { + hash: "00000000000000000000b3ad97907e99c54e6b9145a8f77842e59d9c0c8377cf", + matchRate: 100, + expectedFees: 295107022, + expectedWeight: 3991752 + }, + ... +]` + }, + codeSampleTestnet: { + esModule: [], + commonJS: [], + curl: [`2566570`], + response: `[ + { + hash: "00000000000002e7e96e7b5ee04a5fbb3ef9575a9f4a99effb32a8a89d9d2f19", + matchRate: 100, + expectedFees: 964677, + expectedWeight: 24959 + }, + { + hash: "00000000000003bd3962806d0e06d9982eb2e06aeba912687b2bac3668db32aa", + matchRate: 100, + expectedFees: 631200, + expectedWeight: 15516 + }, + ... +]` + }, + codeSampleSignet: { + esModule: [], + commonJS: [], + curl: [`175504`], + response: `[ + { + hash: "00000012d54289925efc151f2e111e0775e80c3b6bb4b0dcd3ff01dec4bbc5d0", + matchRate: 100, + expectedFees: 4767, + expectedWeight: 2524 + }, + { + hash: "00000031e269cf0b567260b01ae11453175f4598fdb4f1908c5e2f4265b9d93a", + matchRate: 100, + expectedFees: 9090, + expectedWeight: 1851 + }, + ... +]` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, + { + type: "endpoint", + category: "mining", + httpRequestMethod: "GET", + fragment: "get-block-audit-summary", + title: "GET Block Audit Summary", + description: { + default: "Returns the block audit summary for the specified :blockHash. Available fields: height, id, timestamp, template, missingTxs, addedTxs, freshTxs, sigopTxs, fullrbfTxs, acceleratedTxs, matchRate, expectedFees, and expectedWeight." + }, + urlString: ["/v1/block/:blockHash/audit-summary"], + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/block/%{1}/audit-summary`, + commonJS: ``, + esModule: `` + }, + codeSampleMainnet: { + esModule: [], + commonJS: [], + curl: [`00000000000000000000f218ceda7a5d9c289040b9c3f05ef9f7c2f4930e0123`], + response: `{ + height: 822418, + id: "00000000000000000000f218ceda7a5d9c289040b9c3f05ef9f7c2f4930e0123", + timestamp: 1703262962, + template: [ + { + txid: "1de119e4fe0fb92378de74a59fec337c39d505bbc0d04d20d151cc3fb7a91bf0", + fee: 92000, + vsize: 140.25, + value: 354245800, + rate: 655.9714795008913, + flags: 1099511631881 + }, + ... + ], + missingTxs: [], + addedTxs: [ + "3036565d1af6c5b14876a255cdf06214aa350e62154d1ce8619c8e933d0526f8", + "aaa9d8e8f1de712574182a618b4d608f96f39bfc55e296d2e5904561cdef2e77", + ... + ], + freshTxs: [ + "8ede292d8f0319cbe79fff9fd47564cd7f78fad74d7c506d2b157399ff41d904" + ], + sigopTxs: [], + fullrbfTxs: [ + "271e7792910a4ea134c02c03c9d7477b32a8531a5dd92fbc4dbf3ca70614fcce", + "634a5b2de393f0f5b4eeb335bee75c1779b1f2308a07e86cafb95894aa4734d0", + ... + ], + acceleratedTxs: [], + matchRate: 100, + expectedFees: 169464627, + expectedWeight: 3991702 +}` + }, + codeSampleTestnet: { + esModule: [], + commonJS: [], + curl: [`000000000000007cfba94e051326b3546c968a188a7e12e340a78cefc586bfe3`], + response: `{ + height: 2566708, + id: "000000000000007cfba94e051326b3546c968a188a7e12e340a78cefc586bfe3", + timestamp: 1703684826, + template: [ + { + txid: "6556caa3c6bff537f04837a6f7182dd7a253f31a46de4f21dec9584720156d35", + fee: 109707, + vsize: 264.75, + value: 456855, + rate: 414.37960339943345, + flags: 9895621445642 + }, + { + txid: "53b7743b8cfa0108dbcdc7c2f5e661b9d8f56216845a439449d7f9dfc466b147", + fee: 74640, + vsize: 215.5, + value: 19063915, + rate: 348.5338491295938, + flags: 1099528491017 + }, + ... + ], + missingTxs: [ + "8f2eae756119e43054ce1014a06e81d612113794d8b519e6ff393d7e0023396a", + "012b44b0fc0fddc549a056c85850f03a83446c843504c588cd5829873b30f5a9", + ... + ], + addedTxs: [], + freshTxs: [ + "af36a8b88f6c19f997614dfc8a41395190eaf496a49e8db393dacb770999abd5", + "fdfa272c8fe069573b964ddad605d748d8c737e94dfcd09bddaae0ee0a2445df", + ... + ], + sigopTxs: [], + fullrbfTxs: [], + acceleratedTxs: [], + matchRate: 86.96, + expectedFees: 1541639, + expectedWeight: 26425 +}` + }, + codeSampleSignet: { + esModule: [], + commonJS: [], + curl: [`0000008acf5177d07f1d648f4d54f26095936a5d29a0a6145dd75a0415e63c0f`], + response: `{ + height: 175519, + id: "0000008acf5177d07f1d648f4d54f26095936a5d29a0a6145dd75a0415e63c0f", + timestamp: 1703682844, + template: [ + { + txid: "f95b38742c483b81dc4ff49a803bae7625f1596ec5756c944d7586dfe8b38250", + fee: 3766, + vsize: 172.25, + value: 115117171776, + rate: 21.86357039187228, + flags: 1099528425481 + }, + { + txid: "8665c4d05732c930c2037bc0220e4ab9b1b64ce3302363ff7d118827c7347b52", + fee: 3766, + vsize: 172.25, + value: 115116509429, + rate: 21.86357039187228, + flags: 1099528425481 + }, + ... + ], + missingTxs: [], + addedTxs: [], + freshTxs: [], + sigopTxs: [], + fullrbfTxs: [], + acceleratedTxs: [], + matchRate: 100, + expectedFees: 10494, + expectedWeight: 6582 }` }, codeSampleLiquid: emptyCodeSample, @@ -5127,6 +5845,267 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "mempool", + httpRequestMethod: "GET", + fragment: "get-mempool-rbf", + title: "GET Mempool RBF Transactions", + description: { + default: "Returns the list of mempool transactions that are part of a RBF chain." + }, + urlString: "/v1/replacements", + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/replacements`, + commonJS: ``, + esModule: ``, + }, + codeSampleMainnet: { + curl: [], + response: `[ + { + tx: { + txid: "1ca4b22006e57b1b13f5cc89a41cf7c9e99fe225aabf407251e4fe0268f22d93", + fee: 14983, + vsize: 141.5, + value: 343934, + rate: 105.886925795053, + rbf: true, + fullRbf: false + }, + time: 1703331467, + fullRbf: false, + replaces: [ + { + tx: { + txid: "9f8e30674af641bb153a35254d539468e1d847b16bbdc13ce23b5a970b0b11cf", + fee: 13664, + vsize: 141.25, + value: 345253, + rate: 96.7362831858407, + rbf: true + }, + time: 1703331398, + interval: 69, + fullRbf: false, + replaces: [] + } + ] + }, + ... +]` + }, + codeSampleTestnet: { + curl: [], + response: `[ + { + tx: { + txid: "7766e3f008011b776905f96fcad9d4a7b75d1b368d1e77db2901254f1fa8357d", + fee: 9101, + vsize: 317, + value: 147706698, + rate: 28.709779179810724, + rbf: true, + fullRbf: false + }, + time: 1703331325, + fullRbf: false, + replaces: [ + { + tx: { + txid: "43055f6e5750c6aa0c2214e59e99f367398d96bde935e7666c3e648d249a4e40", + fee: 7000, + vsize: 317, + value: 147708799, + rate: 22.082018927444796, + rbf: true + }, + time: 1703331154, + interval: 171, + fullRbf: false, + replaces: [] + } + ] + }, + ... +]` + }, + codeSampleSignet: { + curl: [], + response: `[ + { + tx: { + txid: "13985a5717a1ea54ce720cd6b70421b1667061be491a6799acf6dea01c551248", + fee: 5040, + vsize: 215.5, + value: 762745, + rate: 23.387470997679813, + rbf: true, + fullRbf: false, + mined: true + }, + time: 1703316271, + fullRbf: false, + replaces: [ + { + tx: { + txid: "eac5ec8487414c955f4a5d3b2e516c351aec5299f1335f9019a00907962386ce", + fee: 4560, + vsize: 215.25, + value: 763225, + rate: 21.18466898954704, + rbf: true + }, + time: 1703316270, + interval: 1, + fullRbf: false, + replaces: [] + } + ], + mined: true + } +]` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, + { + type: "endpoint", + category: "mempool", + httpRequestMethod: "GET", + fragment: "get-mempool-fullrbf", + title: "GET Mempool Full RBF Transactions", + description: { + default: "Returns the list of mempool transactions that are part of a Full-RBF chain." + }, + urlString: "/v1/fullrbf/replacements", + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/fullrbf/replacements`, + commonJS: ``, + esModule: ``, + }, + codeSampleMainnet: { + curl: [], + response: `[ + { + tx: { + txid: "25e2bfaf0e0821e5cb71f11e460b2f71e1d5a3755015de42544afa5fbad6d443", + fee: 24436, + vsize: 297.75, + value: 273418, + rate: 82.0688497061293, + rbf: false, + fullRbf: true + }, + time: 1703409882, + fullRbf: true, + replaces: [ + { + tx: { + txid: "07d501e8ad4a25f07f3ced0a6102741720f710765e6fdb2eb966ba0df657997a", + fee: 24138, + vsize: 297.75, + value: 273716, + rate: 81.06801007556675, + rbf: false + }, + time: 1703409853, + interval: 29, + fullRbf: true, + replaces: [] + } + ] + }, + ... +]` + }, + codeSampleTestnet: { + curl: [], + response: `[ + { + tx: { + txid: "25e2bfaf0e0821e5cb71f11e460b2f71e1d5a3755015de42544afa5fbad6d443", + fee: 24436, + vsize: 297.75, + value: 273418, + rate: 82.0688497061293, + rbf: false, + fullRbf: true + }, + time: 1703409882, + fullRbf: true, + replaces: [ + { + tx: { + txid: "07d501e8ad4a25f07f3ced0a6102741720f710765e6fdb2eb966ba0df657997a", + fee: 24138, + vsize: 297.75, + value: 273716, + rate: 81.06801007556675, + rbf: false + }, + time: 1703409853, + interval: 29, + fullRbf: true, + replaces: [] + } + ] + }, + ... +]` + }, + codeSampleSignet: { + curl: [], + response: `[ + { + tx: { + txid: "25e2bfaf0e0821e5cb71f11e460b2f71e1d5a3755015de42544afa5fbad6d443", + fee: 24436, + vsize: 297.75, + value: 273418, + rate: 82.0688497061293, + rbf: false, + fullRbf: true + }, + time: 1703409882, + fullRbf: true, + replaces: [ + { + tx: { + txid: "07d501e8ad4a25f07f3ced0a6102741720f710765e6fdb2eb966ba0df657997a", + fee: 24138, + vsize: 297.75, + value: 273716, + rate: 81.06801007556675, + rbf: false + }, + time: 1703409853, + interval: 29, + fullRbf: true, + replaces: [] + } + ] + }, + ... +]` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, { type: "category", category: "transactions", @@ -5143,7 +6122,7 @@ export const restApiDocsData = [ description: { default: "Returns the ancestors and the best descendant fees for a transaction." }, - urlString: "/v1/fees/cpfp", + urlString: "/v1/cpfp", showConditions: bitcoinNetworks.concat(liquidNetworks), showJsExamples: showJsExamplesDefault, codeExample: { @@ -6000,6 +6979,148 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "transactions", + httpRequestMethod: "GET", + fragment: "get-transaction-rbf-history", + title: "GET Transaction RBF History", + description: { + default: "Returns the RBF tree history of a transaction." + }, + urlString: "v1/tx/:txId/rbf", + showConditions: bitcoinNetworks, + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/tx/%{1}/rbf`, + commonJS: ``, + esModule: ``, + }, + codeSampleMainnet: { + curl: [`2e95ff9094df9f3650e3f2abc189250760162be89a88f9f2f23301c7cb14b8b4`], + response: `{ + replacements: { + tx: { + txid: "2e95ff9094df9f3650e3f2abc189250760162be89a88f9f2f23301c7cb14b8b4", + fee: 1668, + vsize: 276.75, + value: 14849, + rate: 4.824207492795389, + rbf: false, + fullRbf: true + }, + time: 1703240261, + fullRbf: true, + replaces: [ + { + tx: { + txid: "3f4670463daadffed07d7a1060071b07f7e81a2566eca21d78bb513cbf21c82a", + fee: 420, + vsize: 208.25, + value: 4856, + rate: 2.0168067226890756, + rbf: false + }, + time: 1702870898, + interval: 369363, + fullRbf: true, + replaces: [] + } + ... + ] + }, + replaces: [ + "3f4670463daadffed07d7a1060071b07f7e81a2566eca21d78bb513cbf21c82a", + "92f9b4f719d0ffc9035d3a9767d80c940cecbc656df2243bafd33f52b583ee92" + ] +}` + }, + codeSampleTestnet: { + curl: [`5faaa30530bee55de8cc896bdf48f803c2274a94bffc2842386bec2a8bf7a813`], + response: `{ + replacements: { + tx: { + txid: "5faaa30530bee55de8cc896bdf48f803c2274a94bffc2842386bec2a8bf7a813", + fee: 9101, + vsize: 318, + value: 148022607, + rate: 28.61949685534591, + rbf: true, + fullRbf: false, + mined: true + }, + time: 1703322610, + fullRbf: false, + replaces: [ + { + tx: { + txid: "06e69641fa889fe9148669ac2904929004e7140087bedaec8c8e4e05aabded52", + fee: 7000, + vsize: 318, + value: 148024708, + rate: 22.0125786163522, + rbf: true + }, + time: 1703322602, + interval: 8, + fullRbf: false, + replaces: [] + } + ], + mined: true + }, + replaces: [ + "06e69641fa889fe9148669ac2904929004e7140087bedaec8c8e4e05aabded52" + ] +}` + }, + codeSampleSignet: { + curl: [`13985a5717a1ea54ce720cd6b70421b1667061be491a6799acf6dea01c551248`], + response: `{ + replacements: { + tx: { + txid: "13985a5717a1ea54ce720cd6b70421b1667061be491a6799acf6dea01c551248", + fee: 5040, + vsize: 215.5, + value: 762745, + rate: 23.387470997679813, + rbf: true, + fullRbf: false, + mined: true + }, + time: 1703316272, + fullRbf: false, + replaces: [ + { + tx: { + txid: "eac5ec8487414c955f4a5d3b2e516c351aec5299f1335f9019a00907962386ce", + fee: 4560, + vsize: 215.25, + value: 763225, + rate: 21.18466898954704, + rbf: true + }, + time: 1703316270, + interval: 2, + fullRbf: false, + replaces: [] + } + ], + mined: true + }, + replaces: [ + "eac5ec8487414c955f4a5d3b2e516c351aec5299f1335f9019a00907962386ce" + ] +}` + }, + codeSampleLiquid: emptyCodeSample, + codeSampleLiquidTestnet: emptyCodeSample, + codeSampleBisq: emptyCodeSample, + } + } + }, { type: "endpoint", category: "transactions", @@ -6098,6 +7219,48 @@ export const restApiDocsData = [ } } }, + { + type: "endpoint", + category: "transactions", + httpRequestMethod: "GET", + fragment: "get-transaction-times", + title: "GET Transaction Times", + description: { + default: "Returns the timestamps when a list of unconfirmed transactions was initially observed in the mempool. If a transaction is not found in the mempool or has been mined, the timestamp will be 0." + }, + urlString: "/v1/transaction-times", + showConditions: bitcoinNetworks.concat(liquidNetworks), + showJsExamples: showJsExamplesDefaultFalse, + codeExample: { + default: { + codeTemplate: { + curl: `/api/v1/transaction-times?txId[]=%{1}&txId[]=%{2}`, + commonJS: ``, + esModule: ``, + }, + codeSampleMainnet: { + curl: ['51545ef0ec7f09196e60693b59369a134870985c8a90e5d42655b191de06285e', '6086089bd1c56a9c42a39d470cdfa7c12d4b52bf209608b390dfc4943f2d3851'], + response: `[1703082129,1702325558]` + }, + codeSampleTestnet: { + curl: ['25e7a95ebf10ed192ee91741653d8d970ac88f8e0cd6fb14cc6c7145116d3964', '1e158327e52acae35de94962e60e53fc70f6b175b0cfc3e2058bed4b895203b4'], + response: `[1703267563,1703267322]` + }, + codeSampleSignet: { + curl: ['8af0c5199acd89621244f2f61107fe5a9c7c7aad54928e8400651d03ca949aeb', '08f840f7b0c33c5b0fdadf1666e8a8c206836993d95fc1eeeef39b5ef9de03d0'], + response: `[1703267652,1703267696]` + }, + codeSampleLiquid: { + curl: ['6091498f06a3054f82a0c3e5be0a23030185c658dc3568684b0bccc4e759be11', '631212a073aa4ca392e3aeb469d1366ec2ee288988b106e4a6fc8dae8c4d7a9a'], + response: `[1703267652,1703267696]`, + }, + codeSampleLiquidTestnet: { + curl: ['fa8d43e47b2c4bbee12fd8bc1c7440028be2da6ac0f1df6ac77c983938c503fb', '26b12cd450f8fa8b6a527578db218bf212a60b2d5eb65c168f8eb3be6f5fd991'], + response: `[1703268185,1703268209]`, + }, + } + } + }, { type: "endpoint", category: "transactions", @@ -8918,6 +10081,27 @@ export const faqData = [ fragment: "how-do-mempool-goggles-work", title: "How do Mempool Goggles work?", }, + { + type: "endpoint", + category: "advanced", + showConditions: bitcoinNetworks, + fragment: "what-are-sigops", + title: "What are sigops?", + }, + { + type: "endpoint", + category: "advanced", + showConditions: bitcoinNetworks, + fragment: "what-is-adjusted-vsize", + title: "What is adjusted vsize?", + }, + { + type: "endpoint", + category: "advanced", + showConditions: bitcoinNetworks, + fragment: "why-do-the-projected-block-fee-ranges-overlap", + title: "Why do the projected block fee ranges overlap?", + }, { type: "category", category: "self-hosting", diff --git a/frontend/src/app/docs/api-docs/api-docs.component.html b/frontend/src/app/docs/api-docs/api-docs.component.html index 77cf01326..c3a260995 100644 --- a/frontend/src/app/docs/api-docs/api-docs.component.html +++ b/frontend/src/app/docs/api-docs/api-docs.component.html @@ -368,6 +368,28 @@ + +

A "sigop" is a way of accounting for the cost of "signature operations" in Bitcoin script, like OP_CHECKSIG, OP_CHECKSIGVERIFY, OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY

+

These signature operations incur different costs depending on whether they are single or multi-sig operations, and on where they appear in a Bitcoin transaction.

+

By consensus, each Bitcoin block is permitted to include a maximum of 80,000 sigops.

+
+ + +

Bitcoin blocks have two independent consensus-enforced resource constraints - a 4MWU weight limit, and the 80,000 sigop limit.

+

Most transactions use a more of the weight limit than the sigop limit. However, some transactions use a disproportionate number of sigops compared to their weight.

+

To account for this, Bitcoin Core calculates and uses an "adjusted vsize" equal 5 times the number of sigops, or the unadjusted vsize, whichever is larger.

+

Then, during block template construction, Bitcoin Core selects transactions in descending order of fee rate measured in satoshis per adjusted vsize

+

On mempool.space, effective fee rates for unconfirmed transactions are also measured in terms of satoshis per adjusted vsize, after accounting for CPFP relationships and other dependencies.

+
+ + +

The projected mempool blocks represent what we expect the next blocks would look like if they were mined right now, and so each projected block follows all of the same rules and constraints as real mined blocks.

+

Those constraints can sometimes cause transactions with lower fee rates to be included "ahead" of transactions with higher rates.

+

For example, if one projected block has a very small amount of space left, it might be able to fit one more tiny low fee rate transaction, while larger higher fee rate transactions have to wait for the following block.

+

A similar effect can occur when there are a large number of transactions with very many sigops. In that scenario, each projected block can only include up to 80,000 sigops worth of transactions, after which the remaining space can only be filled by potentially much lower fee transactions with zero sigops.

+

In extreme cases this can produce several projected blocks in a row with overlapping fee ranges, as a result of each projected block containing both high-feerate high-sigop transactions and lower feerate zero-sigop transactions.

+
+ The official mempool.space website is operated by The Mempool Open Source Project. See more information on our About page. There are also many unofficial instances of this website operated by individual members of the Bitcoin community. diff --git a/frontend/src/app/liquid/liquid-master-page.module.ts b/frontend/src/app/liquid/liquid-master-page.module.ts index 10d87bc4b..17fa6b8e5 100644 --- a/frontend/src/app/liquid/liquid-master-page.module.ts +++ b/frontend/src/app/liquid/liquid-master-page.module.ts @@ -10,6 +10,7 @@ import { PushTransactionComponent } from '../components/push-transaction/push-tr import { BlocksList } from '../components/blocks-list/blocks-list.component'; import { AssetGroupComponent } from '../components/assets/asset-group/asset-group.component'; import { AssetsComponent } from '../components/assets/assets.component'; +import { AssetsFeaturedComponent } from '../components/assets/assets-featured/assets-featured.component' import { AssetComponent } from '../components/asset/asset.component'; import { AssetsNavComponent } from '../components/assets/assets-nav/assets-nav.component'; @@ -73,6 +74,11 @@ const routes: Routes = [ data: { networks: ['liquid'] }, component: AssetsComponent, }, + { + path: 'featured', + data: { networks: ['liquid'] }, + component: AssetsFeaturedComponent, + }, { path: 'asset/:id', data: { networkSpecific: true }, diff --git a/frontend/src/styles.scss b/frontend/src/styles.scss index be8cec328..8a4fe3c9a 100644 --- a/frontend/src/styles.scss +++ b/frontend/src/styles.scss @@ -1191,3 +1191,7 @@ app-global-footer { line-height: 0.5; border-radius: 0.2rem; } + +.info-link fa-icon { + color: rgba(255, 255, 255, 0.4); +}