From d7ac326f920ae40fe7e93c140ad3760ac5ab4d98 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sun, 23 Jul 2023 12:02:04 +0900 Subject: [PATCH 001/128] [block list] improve block list when db = false --- .../blocks-list/blocks-list.component.html | 66 ++++++++++--------- .../blocks-list/blocks-list.component.ts | 17 +++-- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/frontend/src/app/components/blocks-list/blocks-list.component.html b/frontend/src/app/components/blocks-list/blocks-list.component.html index 39fbb95e0..6248e6868 100644 --- a/frontend/src/app/components/blocks-list/blocks-list.component.html +++ b/frontend/src/app/components/blocks-list/blocks-list.component.html @@ -1,6 +1,6 @@ -
+

Blocks

@@ -9,28 +9,28 @@
- - + - - + - - - - + + - - + + - - - - - - - - - - - - - - - - - - diff --git a/frontend/src/app/components/blocks-list/blocks-list.component.ts b/frontend/src/app/components/blocks-list/blocks-list.component.ts index 1af6572fc..b1c40ec6f 100644 --- a/frontend/src/app/components/blocks-list/blocks-list.component.ts +++ b/frontend/src/app/components/blocks-list/blocks-list.component.ts @@ -17,6 +17,7 @@ export class BlocksList implements OnInit { blocks$: Observable = undefined; + isMempoolModule = false; indexingAvailable = false; auditAvailable = false; isLoading = true; @@ -36,6 +37,7 @@ export class BlocksList implements OnInit { public stateService: StateService, private cd: ChangeDetectorRef, ) { + this.isMempoolModule = this.stateService.env.BASE_MODULE === 'mempool'; } ngOnInit(): void { @@ -64,11 +66,10 @@ export class BlocksList implements OnInit { this.lastBlockHeight = Math.max(...blocks.map(o => o.height)); }), map(blocks => { - if (this.indexingAvailable) { + if (this.stateService.env.BASE_MODULE === 'mempool') { for (const block of blocks) { // @ts-ignore: Need to add an extra field for the template - block.extras.pool.logo = `/resources/mining-pools/` + - block.extras.pool.name.toLowerCase().replace(' ', '').replace('.', '') + '.svg'; + block.extras.pool.logo = `/resources/mining-pools/` + block.extras.pool.name.toLowerCase().replace(' ', '').replace('.', '') + '.svg'; } } if (this.widget) { @@ -99,7 +100,7 @@ export class BlocksList implements OnInit { } if (blocks[1]) { this.blocksCount = Math.max(this.blocksCount, blocks[1][0].height) + 1; - if (this.stateService.env.MINING_DASHBOARD) { + if (this.isMempoolModule) { // @ts-ignore: Need to add an extra field for the template blocks[1][0].extras.pool.logo = `/resources/mining-pools/` + blocks[1][0].extras.pool.name.toLowerCase().replace(' ', '').replace('.', '') + '.svg'; @@ -110,9 +111,11 @@ export class BlocksList implements OnInit { return acc; }, []), switchMap((blocks) => { - blocks.forEach(block => { - block.extras.feeDelta = block.extras.expectedFees ? (block.extras.totalFees - block.extras.expectedFees) / block.extras.expectedFees : 0; - }); + if (this.isMempoolModule && this.auditAvailable) { + blocks.forEach(block => { + block.extras.feeDelta = block.extras.expectedFees ? (block.extras.totalFees - block.extras.expectedFees) / block.extras.expectedFees : 0; + }); + } return of(blocks); }) ); From 597073c9b6ae5eae166690aa7fcf1e3c5745a292 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sun, 23 Jul 2023 12:18:21 +0900 Subject: [PATCH 002/128] [block list] re-enable block fee if !auditAvailable in widget --- .../src/app/components/blocks-list/blocks-list.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/components/blocks-list/blocks-list.component.html b/frontend/src/app/components/blocks-list/blocks-list.component.html index 6248e6868..85e2ea17f 100644 --- a/frontend/src/app/components/blocks-list/blocks-list.component.html +++ b/frontend/src/app/components/blocks-list/blocks-list.component.html @@ -17,7 +17,7 @@ i18n-ngbTooltip="latest-blocks.health" ngbTooltip="Health" placement="bottom" #health [disableTooltip]="!isEllipsisActive(health)">Health - + @@ -65,7 +65,7 @@ - - +
HeightHeightPoolTimestampTimestampHealthRewardFeesFeesTXsTransactionsSizeTransactionsSize
{{ block.height }} -
+
+
@@ -38,11 +38,17 @@ {{ block.extras.coinbaseRaw | hex2ascii }}
+
+ + {{ block.extras.pool.name }} + {{ block.extras.coinbaseRaw | hex2ascii }} +
+ ‎{{ block.timestamp * 1000 | date:'yyyy-MM-dd HH:mm' }} + Unknown + + + {{ block.extras.feeDelta > 0 ? '+' : '' }}{{ (block.extras.feeDelta * 100) | amountShortener: 2 }}% + {{ block.tx_count | number }} +
@@ -82,34 +88,34 @@
+ + + + + + + + + +
RewardFeesFees TXs + From fc73dcc3444b73b31110c45734a0155524302685 Mon Sep 17 00:00:00 2001 From: Stephan Oeste Date: Mon, 7 Aug 2023 20:08:30 +0200 Subject: [PATCH 003/128] Fixing proxy_buffer_size error nginx.conf --- production/nginx/http-proxy-cache.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/production/nginx/http-proxy-cache.conf b/production/nginx/http-proxy-cache.conf index f870939b3..60c6d4f82 100644 --- a/production/nginx/http-proxy-cache.conf +++ b/production/nginx/http-proxy-cache.conf @@ -3,3 +3,4 @@ proxy_cache_path /var/cache/nginx/api keys_zone=api:20m levels=1:2 inactive=600s proxy_cache_path /var/cache/nginx/services keys_zone=services:20m levels=1:2 inactive=600s max_size=100m; proxy_cache_path /var/cache/nginx/markets keys_zone=markets:20m levels=1:2 inactive=600s max_size=100m; types_hash_max_size 2048; +proxy_buffer_size 8k; From 45ba50e82cb6f884583bb75c1aed44c5d1036269 Mon Sep 17 00:00:00 2001 From: hunicus <93150691+hunicus@users.noreply.github.com> Date: Thu, 10 Aug 2023 16:26:07 +0900 Subject: [PATCH 004/128] Change citadel link on about page --- frontend/src/app/components/about/about.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/components/about/about.component.html b/frontend/src/app/components/about/about.component.html index e9d5ec3b2..b9ef7a8cf 100644 --- a/frontend/src/app/components/about/about.component.html +++ b/frontend/src/app/components/about/about.component.html @@ -257,7 +257,7 @@ RoninDojo - + Citadel From ab911d5c9eca061bbdd85a71eceb919c3a95deb5 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Thu, 17 Aug 2023 14:28:33 +0200 Subject: [PATCH 005/128] [tx] fix eta css with accelerate button --- .../components/transaction/transaction.component.html | 10 ++++++---- .../components/transaction/transaction.component.ts | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 133bcaa1d..ddbfd0bb3 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -99,9 +99,10 @@ - + In several hours (or more) - Accelerate + + Accelerate @@ -109,9 +110,10 @@ - + - Accelerate + + Accelerate diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index f1f3850e4..d12be2084 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -82,6 +82,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { blockConversion: Price; tooltipPosition: { x: number, y: number }; isMobile: boolean; + acceleratorAvailable: boolean = false; featuresEnabled: boolean; segwitEnabled: boolean; @@ -107,6 +108,8 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { ) {} ngOnInit() { + this.acceleratorAvailable = this.stateService.env.OFFICIAL_MEMPOOL_SPACE && this.stateService.env.ACCELERATOR && this.stateService.network === ''; + this.websocketService.want(['blocks', 'mempool-blocks']); this.stateService.networkChanged$.subscribe( (network) => (this.network = network) From 23b871631a83e894b9d011cc3b17493b4f973b6e Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Thu, 17 Aug 2023 18:51:39 +0200 Subject: [PATCH 006/128] [menu] write menu component with hardcoded values --- .../master-page/master-page.component.html | 4 +- .../app/components/menu/menu.component.html | 17 +++++++ .../app/components/menu/menu.component.scss | 46 +++++++++++++++++ .../src/app/components/menu/menu.component.ts | 23 +++++++++ .../src/app/interfaces/services.interface.ts | 13 +++++ frontend/src/app/services/api.service.ts | 50 ++++++++++++++++++- frontend/src/app/shared/shared.module.ts | 20 +++++++- 7 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 frontend/src/app/components/menu/menu.component.html create mode 100644 frontend/src/app/components/menu/menu.component.scss create mode 100644 frontend/src/app/components/menu/menu.component.ts create mode 100644 frontend/src/app/interfaces/services.interface.ts diff --git a/frontend/src/app/components/master-page/master-page.component.html b/frontend/src/app/components/master-page/master-page.component.html index f12fbc960..77212b1a3 100644 --- a/frontend/src/app/components/master-page/master-page.component.html +++ b/frontend/src/app/components/master-page/master-page.component.html @@ -1,5 +1,7 @@ + + -
+
ETAETA - - In several hours (or more) - Accelerate + + In several hours (or more) + @@ -109,9 +144,11 @@ - - - Accelerate + + + diff --git a/frontend/src/app/components/transaction/transaction.component.scss b/frontend/src/app/components/transaction/transaction.component.scss index 5bef401d7..45357471a 100644 --- a/frontend/src/app/components/transaction/transaction.component.scss +++ b/frontend/src/app/components/transaction/transaction.component.scss @@ -228,11 +228,15 @@ } } +.link.accelerator { + cursor: pointer; +} + .accelerate { align-self: auto; margin-top: 3px; + margin-left: 10px; @media (min-width: 850px) { justify-self: start; - margin-left: 0px; } } \ No newline at end of file diff --git a/frontend/src/app/components/transaction/transaction.component.ts b/frontend/src/app/components/transaction/transaction.component.ts index f1f3850e4..db200e9b1 100644 --- a/frontend/src/app/components/transaction/transaction.component.ts +++ b/frontend/src/app/components/transaction/transaction.component.ts @@ -19,6 +19,7 @@ import { WebsocketService } from '../../services/websocket.service'; import { AudioService } from '../../services/audio.service'; import { ApiService } from '../../services/api.service'; import { SeoService } from '../../services/seo.service'; +import { StorageService } from '../../services/storage.service'; import { BlockExtended, CpfpInfo, RbfTree, MempoolPosition, DifficultyAdjustment } from '../../interfaces/node-api.interface'; import { LiquidUnblinding } from './liquid-ublinding'; import { RelativeUrlPipe } from '../../shared/pipes/relative-url/relative-url.pipe'; @@ -88,6 +89,9 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { rbfEnabled: boolean; taprootEnabled: boolean; hasEffectiveFeeRate: boolean; + accelerateCtaType: 'alert' | 'button' = 'alert'; + acceleratorAvailable: boolean = this.stateService.env.OFFICIAL_MEMPOOL_SPACE && this.stateService.env.ACCELERATOR && this.stateService.network === ''; + showAccelerationSummary = false; @ViewChild('graphContainer') graphContainer: ElementRef; @@ -104,14 +108,20 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { private apiService: ApiService, private seoService: SeoService, private priceService: PriceService, + private storageService: StorageService ) {} ngOnInit() { this.websocketService.want(['blocks', 'mempool-blocks']); this.stateService.networkChanged$.subscribe( - (network) => (this.network = network) + (network) => { + this.network = network; + this.acceleratorAvailable = this.stateService.env.OFFICIAL_MEMPOOL_SPACE && this.stateService.env.ACCELERATOR && this.stateService.network === ''; + } ); + this.accelerateCtaType = (this.storageService.getValue('accel-cta-type') as 'alert' | 'button') ?? 'alert'; + this.setFlowEnabled(); this.flowPrefSubscription = this.stateService.hideFlow.subscribe((hide) => { this.hideFlow = !!hide; @@ -486,6 +496,19 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy { this.setGraphSize(); } + dismissAccelAlert(): void { + this.storageService.setValue('accel-cta-type', 'button'); + this.accelerateCtaType = 'button'; + } + + onAccelerateClicked(): void { + if (!this.txId) { + return; + } + + this.showAccelerationSummary = true && this.acceleratorAvailable; + } + handleLoadElectrsTransactionError(error: any): Observable { if (error.status === 404 && /^[a-fA-F0-9]{64}$/.test(this.txId)) { this.websocketService.startMultiTrackTransaction(this.txId); diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index cd1109da1..2d9077a97 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -388,4 +388,8 @@ export class ApiService { getServicesBackendInfo$(): Observable { return this.httpClient.get(`${SERVICES_API_PREFIX}/version`); } + + estimate$(txInput: string) { + return this.httpClient.post(`${SERVICES_API_PREFIX}/accelerator/estimate`, { txInput: txInput }, { observe: 'response' }); + } } diff --git a/frontend/src/app/shared/components/confirmations/confirmations.component.html b/frontend/src/app/shared/components/confirmations/confirmations.component.html index db3f1f38a..4ad3cb33a 100644 --- a/frontend/src/app/shared/components/confirmations/confirmations.component.html +++ b/frontend/src/app/shared/components/confirmations/confirmations.component.html @@ -1,19 +1,19 @@ - - + - + - + - + \ No newline at end of file diff --git a/frontend/src/app/shared/components/confirmations/confirmations.component.scss b/frontend/src/app/shared/components/confirmations/confirmations.component.scss index e69de29bb..c8af7dd76 100644 --- a/frontend/src/app/shared/components/confirmations/confirmations.component.scss +++ b/frontend/src/app/shared/components/confirmations/confirmations.component.scss @@ -0,0 +1,4 @@ +.no-cursor { + cursor: default !important; + pointer-events: none; +} \ No newline at end of file From c1b2f1f2c7d575b65ca679aa55577f9e373df7a2 Mon Sep 17 00:00:00 2001 From: wiz Date: Fri, 25 Aug 2023 23:24:51 +0900 Subject: [PATCH 049/128] ops: Disable tor in prod install script --- production/install | 71 +++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/production/install b/production/install index 67e2f7d78..13449a904 100755 --- a/production/install +++ b/production/install @@ -1857,22 +1857,22 @@ ln -s "${MEMPOOL_HOME}/mempool" "${NGINX_ETC_FOLDER}/mempool" osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_USER__!${NGINX_USER}!" "${NGINX_CONFIGURATION}" osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_ETC_FOLDER__!${NGINX_ETC_FOLDER}!" "${NGINX_CONFIGURATION}" -if [ "${TOR_INSTALL}" = ON ];then - echo "[*] Read tor v3 onion hostnames" - - NGINX_MEMPOOL_ONION=$(cat "${TOR_RESOURCES}/mempool/hostname") - osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_MEMPOOL_ONION__!${NGINX_MEMPOOL_ONION%.onion}!" "${NGINX_CONFIGURATION}" - - if [ "${ELEMENTS_LIQUID_ENABLE}" = "ON" ];then - NGINX_LIQUID_ONION=$(cat "${TOR_RESOURCES}/liquid/hostname") - osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_LIQUID_ONION__!${NGINX_LIQUID_ONIONi%.onion}!" "${NGINX_CONFIGURATION}" - fi - - if [ "${BISQ_MAINNET_ENABLE}" = "ON" ];then - NGINX_BISQ_ONION=$(cat "${TOR_RESOURCES}/bisq/hostname") - osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_BISQ_ONION__!${NGINX_BISQ_ONION%.onion}!" "${NGINX_CONFIGURATION}" - fi -fi +#if [ "${TOR_INSTALL}" = ON ];then +# echo "[*] Read tor v3 onion hostnames" +# +# NGINX_MEMPOOL_ONION=$(cat "${TOR_RESOURCES}/mempool/hostname") +# osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_MEMPOOL_ONION__!${NGINX_MEMPOOL_ONION%.onion}!" "${NGINX_CONFIGURATION}" +# +# if [ "${ELEMENTS_LIQUID_ENABLE}" = "ON" ];then +# NGINX_LIQUID_ONION=$(cat "${TOR_RESOURCES}/liquid/hostname") +# osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_LIQUID_ONION__!${NGINX_LIQUID_ONIONi%.onion}!" "${NGINX_CONFIGURATION}" +# fi +# +# if [ "${BISQ_MAINNET_ENABLE}" = "ON" ];then +# NGINX_BISQ_ONION=$(cat "${TOR_RESOURCES}/bisq/hostname") +# osSudo "${ROOT_USER}" sed -i.orig "s!__NGINX_BISQ_ONION__!${NGINX_BISQ_ONION%.onion}!" "${NGINX_CONFIGURATION}" +# fi +#fi ##### OS systemd @@ -1896,13 +1896,26 @@ echo "[*] Updating system startup configuration" case $OS in FreeBSD) - echo 'nginx_enable="YES"' >> /etc/rc.conf - echo 'bitcoin_enable="YES"' >> /etc/rc.conf - echo 'tor_enable="YES"' >> /etc/rc.conf - echo 'postfix_enable="YES"' >> /etc/rc.conf - echo 'mysql_enable="YES"' >> /etc/rc.conf - echo 'mysql_dbdir="/mysql"' >> /etc/rc.conf - echo 'tor_enable="YES"' >> /etc/rc.conf + cat >> /etc/rc.conf < Date: Fri, 25 Aug 2023 23:29:03 +0900 Subject: [PATCH 050/128] ops: Increase FreeBSD bitcoin node shutdown timeout to 600 --- production/freebsd/rc.d/bitcoin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/production/freebsd/rc.d/bitcoin b/production/freebsd/rc.d/bitcoin index 76c217589..c22fbbabc 100644 --- a/production/freebsd/rc.d/bitcoin +++ b/production/freebsd/rc.d/bitcoin @@ -48,7 +48,7 @@ load_rc_config ${name} : ${bitcoin_syslog_facility:="local0"} : ${bitcoin_syslog_priority:="info"} : ${bitcoin_syslog_tag:="bitcoin"} -: ${bitcoin_kill_after:="300"} +: ${bitcoin_kill_after:="600"} : ${bitcoinlimits_args:="-e -U ${bitcoin_user}"} # set up dependant variables From 0fde6dd908864b741fa0adb82e6fb007a462a1a1 Mon Sep 17 00:00:00 2001 From: wiz Date: Fri, 25 Aug 2023 23:34:50 +0900 Subject: [PATCH 051/128] ops: Bump prod NodeJS version to v20.5.1 --- production/install | 8 +++----- production/mempool-start-all | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/production/install b/production/install index 13449a904..7ab1e657b 100755 --- a/production/install +++ b/production/install @@ -1045,11 +1045,9 @@ osSudo "${ROOT_USER}" crontab -u "${MEMPOOL_USER}" "${MEMPOOL_HOME}/${MEMPOOL_RE echo "[*] Installing nvm.sh from GitHub" osSudo "${MEMPOOL_USER}" sh -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | zsh' -echo "[*] Building NodeJS v20.4.0 via nvm.sh" -osSudo "${MEMPOOL_USER}" zsh -c 'source ~/.zshrc ; nvm install v20.4.0 --shared-zlib' -echo "[*] Building NodeJS v18.16.1 via nvm.sh" -osSudo "${MEMPOOL_USER}" zsh -c 'source ~/.zshrc ; nvm install v18.16.1 --shared-zlib' -osSudo "${MEMPOOL_USER}" zsh -c 'source ~/.zshrc ; nvm alias default 18.16.1' +echo "[*] Building NodeJS v20.5.1 via nvm.sh" +osSudo "${MEMPOOL_USER}" zsh -c 'source ~/.zshrc ; nvm install v20.5.1 --shared-zlib' +osSudo "${MEMPOOL_USER}" zsh -c 'source ~/.zshrc ; nvm alias default 20.5.1' #################### # Tor installation # diff --git a/production/mempool-start-all b/production/mempool-start-all index 7efbf7dd6..5b4f85577 100755 --- a/production/mempool-start-all +++ b/production/mempool-start-all @@ -1,7 +1,7 @@ #!/usr/bin/env zsh export NVM_DIR="$HOME/.nvm" source "$NVM_DIR/nvm.sh" -nvm use v20.4.0 +nvm use v20.5.1 # start all mempool backends that exist for site in mainnet mainnet-lightning testnet testnet-lightning signet signet-lightning bisq liquid liquidtestnet;do From dc44f1b618cf364a1eeddbb6c298cf1fca9ed47c Mon Sep 17 00:00:00 2001 From: wiz Date: Sat, 26 Aug 2023 04:40:12 +0900 Subject: [PATCH 052/128] ops: Fix WebGL for unfurler --- unfurler/puppeteer.config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unfurler/puppeteer.config.json b/unfurler/puppeteer.config.json index 4d525755e..583ce7148 100644 --- a/unfurler/puppeteer.config.json +++ b/unfurler/puppeteer.config.json @@ -42,6 +42,6 @@ "--use-mock-keychain", "--ignore-gpu-blacklist", "--ignore-gpu-blocklist", - "--use-gl=egl" + "--use-angle=default" ] } From d42a3f74ec895f5b5921a2669b0daf55196d6964 Mon Sep 17 00:00:00 2001 From: hunicus <93150691+hunicus@users.noreply.github.com> Date: Sat, 26 Aug 2023 14:18:55 +0900 Subject: [PATCH 053/128] Add description to index html and seo service --- frontend/src/app/services/seo.service.ts | 6 ++++++ frontend/src/index.bisq.html | 18 +++++++++--------- frontend/src/index.liquid.html | 17 +++++++++-------- frontend/src/index.mempool.html | 17 +++++++++-------- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/frontend/src/app/services/seo.service.ts b/frontend/src/app/services/seo.service.ts index 4fc25be52..37387e6bf 100644 --- a/frontend/src/app/services/seo.service.ts +++ b/frontend/src/app/services/seo.service.ts @@ -52,6 +52,12 @@ export class SeoService { this.resetTitle(); } + setDescription(newDescription: string): void { + this.metaService.updateTag({ name: 'description', content: newDescription}); + this.metaService.updateTag({ name: 'twitter:description', content: newDescription}); + this.metaService.updateTag({ property: 'og:description', content: newDescription}); + } + getTitle(): string { if (this.network === 'testnet') return this.baseTitle + ' - Bitcoin Testnet'; diff --git a/frontend/src/index.bisq.html b/frontend/src/index.bisq.html index 6d3bcb130..614c06bd4 100644 --- a/frontend/src/index.bisq.html +++ b/frontend/src/index.bisq.html @@ -7,18 +7,18 @@ - + - - - - - - - - + + + + + + + + diff --git a/frontend/src/index.liquid.html b/frontend/src/index.liquid.html index ce57e5873..37e4241a0 100644 --- a/frontend/src/index.liquid.html +++ b/frontend/src/index.liquid.html @@ -7,18 +7,19 @@ - + - - - - - - - + + + + + + + + diff --git a/frontend/src/index.mempool.html b/frontend/src/index.mempool.html index ec026b63b..e0816f6b3 100644 --- a/frontend/src/index.mempool.html +++ b/frontend/src/index.mempool.html @@ -7,18 +7,19 @@ - + - - - - - - - + + + + + + + + From fcecbe49677144328c743ba86b6d3fbd95305cc8 Mon Sep 17 00:00:00 2001 From: nymkappa <1612910616@pm.me> Date: Sat, 26 Aug 2023 09:52:55 +0200 Subject: [PATCH 054/128] [tx] integrated accelerator --- .../accelerate-preview.component.html | 231 ++++++++++++++++++ .../accelerate-preview.component.scss | 20 ++ .../accelerate-preview.component.ts | 163 +++++++++++- .../transaction/transaction.component.html | 32 +-- .../transaction/transaction.component.scss | 59 +++-- .../transaction/transaction.component.ts | 7 +- frontend/src/app/services/api.service.ts | 4 + .../mempool-error.component.html | 2 + .../mempool-error/mempool-error.component.ts | 47 ++++ frontend/src/app/shared/shared.module.ts | 8 +- 10 files changed, 519 insertions(+), 54 deletions(-) create mode 100644 frontend/src/app/shared/components/mempool-error/mempool-error.component.html create mode 100644 frontend/src/app/shared/components/mempool-error/mempool-error.component.ts diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html index e69de29bb..e2c6e3c22 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.html @@ -0,0 +1,231 @@ +
+
+
+ Transaction has now been submitted to mining pools for acceleration. You can track the progress here. +
+
+
+ +
+
+ +
+
+ +
+
+
+ This transactions is part of a CPFP tree. Fee rates (in sats/vb) are provided for your information. Change in the CPFP tree will lead to different fee rates values. +
+
+
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Next block market price + + {{ estimate.targetFeeRate | number : '1.0-0' }} sat/vB +
+ Currently estimated fee to get into next block + + + {{ estimate.nextBlockFee| number }} sats + + +
+ Fees paid in-band + + ~{{ (estimate.txSummary.effectiveFee / estimate.txSummary.effectiveVsize) | number : '1.0-0' }} sat/vB +
+ What you already paid when you made the transaction + + + {{ estimate.txSummary.effectiveFee | number }} sats + + +
+ Extra fee required + + {{ math.max(0, estimate.nextBlockFee - estimate.txSummary.effectiveFee) | number }} sats + +
+ Difference between the next block fee and your tx fee +
+
+
+ +
How much more are you willing to pay at most to get into the next block?
+
+
+ + The maximum extra transaction fee you're willing to pay to get into the next block. If the next block market price becomes too expensive for you, we will automatically cancel your acceleration request. Final charged fee may be smaller based on the fee market. + +
+
+
+ + + + +
+
+
+
+
+ +
Acceleration summary
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Your maximum tx fees + + ~{{ ((estimate.txSummary.effectiveFee + userBid) / estimate.txSummary.effectiveVsize) | number : '1.0-0' }} sat/vB +
+ The maximum extra transaction fee you're willing to pay + + + {{ userBid | number }} sats + + +
+ Mempool Acceleratorâ„¢ fee + + +{{ estimate.mempoolBaseFee + estimate.vsizeFee | number }} sats + +
+ mempool.space fee + + + {{ estimate.mempoolBaseFee | number }} sats + + +
+ Transaction vsize fee + + + {{ estimate.vsizeFee | number }} sats + + +
+ Estimated acceleration cost + + + {{ estimate.cost + estimate.mempoolBaseFee + estimate.vsizeFee | number }} satss + + +
+ Cost if your tx is accelerated using {{ estimate.targetFeeRate | number : '1.0-0' }} sat/vB +
+ Maximum acceleration cost + + {{ maxCost | number }} satss + + + +
+ Cost if your tx is accelerated using ~{{ ((estimate.txSummary.effectiveFee + userBid) / estimate.txSummary.effectiveVsize) | number : '1.0-0' }} sat/vB +
+ Available balance + + {{ estimate.userBalance | number }} satss + + + +
+
+
+ +
+
+
+ +
+
+
+ +
+
\ No newline at end of file diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.scss b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.scss index e69de29bb..b6981b8a7 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.scss +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.scss @@ -0,0 +1,20 @@ +.fee-card { + padding: 15px; + background-color: #1d1f31; +} + +.btn-border { + border: solid 1px black; + background-color: #0c4a87; +} + +.feerate.active { + background-color: #105fb0 !important; + opacity: 1; + border: 1px solid white !important; +} + +.estimateDisabled { + opacity: 0.5; + pointer-events: none; +} diff --git a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts index dc8b9b5df..bea0efb88 100644 --- a/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts +++ b/frontend/src/app/components/accelerate-preview/accelerate-preview.component.ts @@ -1,24 +1,169 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input, OnDestroy, OnChanges, SimpleChanges } from '@angular/core'; +import { ApiService } from '../../services/api.service'; +import { Subscription, catchError, of, tap } from 'rxjs'; + +export type AccelerationEstimate = { + txSummary: TxSummary; + nextBlockFee: number; + targetFeeRate: number; + userBalance: number; + enoughBalance: boolean; + cost: number; + mempoolBaseFee: number; + vsizeFee: number; +} +export type TxSummary = { + txid: string; // txid of the current transaction + effectiveVsize: number; // Total vsize of the dependency tree + effectiveFee: number; // Total fee of the dependency tree in sats + ancestorCount: number; // Number of ancestors +} + +export const DEFAULT_BID_RATIO = 5; +export const MIN_BID_RATIO = 2; +export const MAX_BID_RATIO = 20; @Component({ - selector: 'app-accelerator-preview', + selector: 'app-accelerate-preview', templateUrl: 'accelerate-preview.component.html', styleUrls: ['accelerate-preview.component.scss'] }) +export class AcceleratePreviewComponent implements OnInit, OnDestroy, OnChanges { + @Input() txid: string | undefined; + @Input() scrollEvent: boolean; + + math = Math; + error = ''; + showSuccess = false; + estimateSubscription: Subscription; + accelerationSubscription: Subscription; + estimate: any; + minExtraCost = 0; + minBidAllowed = 0; + maxBidAllowed = 0; + defaultBid = 0; + maxCost = 0; + userBid = 0; + selectFeeRateIndex = 2; -export class AcceleratePreviewComponent implements OnInit { constructor( private apiService: ApiService ) { } + ngOnDestroy(): void { + if (this.estimateSubscription) { + this.estimateSubscription.unsubscribe(); + } + } + + ngOnChanges(changes: SimpleChanges): void { + if (changes.scrollEvent) { + this.scrollToPreview('acceleratePreviewAnchor', 'center'); + } + } + ngOnInit() { - this.apiService.estimate$(this.txId).subscribe((estimate) => { - console.log(estimate.body); - document.getElementById('acceleratePreviewAnchor').scrollIntoView({ + this.estimateSubscription = this.apiService.estimate$(this.txid).pipe( + tap((response) => { + if (response.status === 204) { + this.estimate = undefined; + this.error = `cannot_accelerate_tx`; + this.scrollToPreviewWithTimeout('mempoolError', 'center'); + this.estimateSubscription.unsubscribe(); + } else { + this.estimate = response.body; + if (!this.estimate) { + this.error = `cannot_accelerate_tx`; + this.scrollToPreviewWithTimeout('mempoolError', 'center'); + this.estimateSubscription.unsubscribe(); + } + + if (this.estimate.userBalance <= 0) { + this.error = `not_enough_balance`; + this.scrollToPreviewWithTimeout('mempoolError', 'center'); + } + + // Make min extra fee at least 50% of the current tx fee + this.minExtraCost = Math.max(this.estimate.cost, this.estimate.txSummary.effectiveFee / 2); + this.minExtraCost = Math.round(this.minExtraCost); + + this.minBidAllowed = this.minExtraCost * MIN_BID_RATIO; + this.maxBidAllowed = this.minExtraCost * MAX_BID_RATIO; + this.defaultBid = this.minExtraCost * DEFAULT_BID_RATIO; + + this.userBid = this.defaultBid; + if (this.userBid < this.minBidAllowed) { + this.userBid = this.minBidAllowed; + } else if (this.userBid > this.maxBidAllowed) { + this.userBid = this.maxBidAllowed; + } + this.maxCost = this.userBid + this.estimate.mempoolBaseFee + this.estimate.vsizeFee; + + if (!this.error) { + this.scrollToPreview('acceleratePreviewAnchor', 'center'); + } + } + }), + catchError((response) => { + this.estimate = undefined; + this.error = response.error; + this.scrollToPreviewWithTimeout('mempoolError', 'center'); + this.estimateSubscription.unsubscribe(); + return of(null); + }) + ).subscribe(); + } + + /** + * User changed his bid + */ + setUserBid(multiplier: number, index: number) { + if (this.estimate) { + this.selectFeeRateIndex = index; + this.userBid = Math.max(0, this.minExtraCost * multiplier); + this.maxCost = this.userBid + this.estimate.mempoolBaseFee + this.estimate.vsizeFee; + } + } + + /** + * Scroll to element id with or without setTimeout + */ + scrollToPreviewWithTimeout(id: string, position: ScrollLogicalPosition) { + setTimeout(() => { + this.scrollToPreview(id, position); + }, 100); + } + scrollToPreview(id: string, position: ScrollLogicalPosition) { + const acceleratePreviewAnchor = document.getElementById(id); + if (acceleratePreviewAnchor) { + acceleratePreviewAnchor.scrollIntoView({ behavior: 'smooth', - inline: 'center', - block: 'center', + inline: position, + block: position, }); - }) + } +} + + /** + * Send acceleration request + */ + accelerate() { + if (this.accelerationSubscription) { + this.accelerationSubscription.unsubscribe(); + } + this.accelerationSubscription = this.apiService.accelerate$( + this.txid, + this.userBid + ).subscribe({ + next: () => { + this.showSuccess = true; + this.scrollToPreviewWithTimeout('successAlert', 'center'); + this.estimateSubscription.unsubscribe(); + }, + error: (response) => { + this.error = response.error; + this.scrollToPreviewWithTimeout('mempoolError', 'center'); + } + }); } } \ No newline at end of file diff --git a/frontend/src/app/components/transaction/transaction.component.html b/frontend/src/app/components/transaction/transaction.component.html index 36c7ab9f3..f7dd45d3b 100644 --- a/frontend/src/app/components/transaction/transaction.component.html +++ b/frontend/src/app/components/transaction/transaction.component.html @@ -6,7 +6,7 @@ -