From 1f0ae601c59450daeb936dbfcd8928ab6e90d399 Mon Sep 17 00:00:00 2001
From: Antoni Spaanderman <56turtle56@gmail.com>
Date: Thu, 20 Jan 2022 17:19:16 +0100
Subject: [PATCH] add network regtest
---
frontend/mempool-frontend-config.sample.json | 1 +
frontend/src/app/app-routing.module.ts | 78 +++++++++++++++++++
.../components/amount/amount.component.html | 3 +-
.../bisq-master-page.component.html | 3 +-
.../app/components/block/block.component.ts | 8 +-
.../blockchain-blocks.component.ts | 1 +
.../liquid-master-page.component.html | 3 +-
.../master-page/master-page.component.html | 3 +-
frontend/src/app/services/seo.service.ts | 2 +
frontend/src/app/services/state.service.ts | 10 ++-
frontend/src/resources/regtest-logo.png | 1 +
11 files changed, 102 insertions(+), 11 deletions(-)
create mode 120000 frontend/src/resources/regtest-logo.png
diff --git a/frontend/mempool-frontend-config.sample.json b/frontend/mempool-frontend-config.sample.json
index 0715cb0bd..b3cbb0b6a 100644
--- a/frontend/mempool-frontend-config.sample.json
+++ b/frontend/mempool-frontend-config.sample.json
@@ -1,6 +1,7 @@
{
"TESTNET_ENABLED": false,
"SIGNET_ENABLED": false,
+ "REGTEST_ENABLED": false,
"LIQUID_ENABLED": false,
"LIQUID_TESTNET_ENABLED": false,
"BISQ_ENABLED": false,
diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index 43705b85e..c72e6d186 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -261,6 +261,84 @@ let routes: Routes = [
},
]
},
+ {
+ path: 'regtest',
+ children: [
+ {
+ path: '',
+ component: MasterPageComponent,
+ children: [
+ {
+ path: 'tx/push',
+ component: PushTransactionComponent,
+ },
+ {
+ path: '',
+ component: StartComponent,
+ children: [
+ {
+ path: '',
+ component: DashboardComponent
+ },
+ {
+ path: 'tx/:id',
+ component: TransactionComponent
+ },
+ {
+ path: 'block/:id',
+ component: BlockComponent
+ },
+ {
+ path: 'mempool-block/:id',
+ component: MempoolBlockComponent
+ },
+ ],
+ },
+ {
+ path: 'blocks',
+ component: LatestBlocksComponent,
+ },
+ {
+ path: 'graphs',
+ component: StatisticsComponent,
+ },
+ {
+ path: 'address/:id',
+ children: [],
+ component: AddressComponent
+ },
+ {
+ path: 'docs/api/:type',
+ component: DocsComponent
+ },
+ {
+ path: 'docs/api',
+ redirectTo: 'docs/api/rest'
+ },
+ {
+ path: 'docs',
+ redirectTo: 'docs/api/rest'
+ },
+ {
+ path: 'api',
+ redirectTo: 'docs/api/rest'
+ },
+ ],
+ },
+ {
+ path: 'tv',
+ component: TelevisionComponent
+ },
+ {
+ path: 'status',
+ component: StatusViewComponent
+ },
+ {
+ path: '**',
+ redirectTo: ''
+ },
+ ]
+ },
{
path: 'tv',
component: TelevisionComponent,
diff --git a/frontend/src/app/components/amount/amount.component.html b/frontend/src/app/components/amount/amount.component.html
index 07f669a81..a3e9ea453 100644
--- a/frontend/src/app/components/amount/amount.component.html
+++ b/frontend/src/app/components/amount/amount.component.html
@@ -10,6 +10,7 @@
L-
tL-
t
- sBTC
+ s
+ rBTC
diff --git a/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html b/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html
index d77f96423..2a2309429 100644
--- a/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html
+++ b/frontend/src/app/components/bisq-master-page/bisq-master-page.component.html
@@ -10,7 +10,7 @@
-
+
@@ -18,6 +18,7 @@
Mainnet
Signet
Testnet
+
Regtest
Liquid
diff --git a/frontend/src/app/components/block/block.component.ts b/frontend/src/app/components/block/block.component.ts
index a3841a3a6..9482d9953 100644
--- a/frontend/src/app/components/block/block.component.ts
+++ b/frontend/src/app/components/block/block.component.ts
@@ -216,12 +216,8 @@ export class BlockComponent implements OnInit, OnDestroy {
this.blockSubsidy = 0;
return;
}
- this.blockSubsidy = 50;
- let halvenings = Math.floor(this.block.height / 210000);
- while (halvenings > 0) {
- this.blockSubsidy = this.blockSubsidy / 2;
- halvenings--;
- }
+ let halvings = Math.floor(this.block.height / (this.network === 'regtest' ? 150 : 210000));
+ this.blockSubsidy = 50 * 2 ** -halvings;
}
pageChange(page: number, target: HTMLElement) {
diff --git a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts
index 6c2babd5a..64fff912d 100644
--- a/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts
+++ b/frontend/src/app/components/blockchain-blocks/blockchain-blocks.component.ts
@@ -39,6 +39,7 @@ export class BlockchainBlocksComponent implements OnInit, OnDestroy {
'liquidtestnet': ['#494a4a', '#272e46'],
testnet: ['#1d486f', '#183550'],
signet: ['#6f1d5d', '#471850'],
+ regtest: ['#6f1d5d', '#471850'],
};
constructor(
diff --git a/frontend/src/app/components/liquid-master-page/liquid-master-page.component.html b/frontend/src/app/components/liquid-master-page/liquid-master-page.component.html
index b3635ceae..e31aa2e25 100644
--- a/frontend/src/app/components/liquid-master-page/liquid-master-page.component.html
+++ b/frontend/src/app/components/liquid-master-page/liquid-master-page.component.html
@@ -11,7 +11,7 @@
-
+
@@ -19,6 +19,7 @@
Mainnet
Signet
Testnet
+
Regtest
Bisq
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 8d871e3b6..a17b59f3b 100644
--- a/frontend/src/app/components/master-page/master-page.component.html
+++ b/frontend/src/app/components/master-page/master-page.component.html
@@ -11,7 +11,7 @@
-
+
@@ -19,6 +19,7 @@
+
Bisq
Liquid
diff --git a/frontend/src/app/services/seo.service.ts b/frontend/src/app/services/seo.service.ts
index fb47b0dc8..452105dce 100644
--- a/frontend/src/app/services/seo.service.ts
+++ b/frontend/src/app/services/seo.service.ts
@@ -31,6 +31,8 @@ export class SeoService {
return 'mempool - Bitcoin Testnet';
if (this.network === 'signet')
return 'mempool - Bitcoin Signet';
+ if (this.network === 'regtest')
+ return 'mempool - Bitcoin Regtest';
if (this.network === 'liquid')
return 'mempool - Liquid Network';
if (this.network === 'liquidtestnet')
diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts
index eebde80ea..64f42eb73 100644
--- a/frontend/src/app/services/state.service.ts
+++ b/frontend/src/app/services/state.service.ts
@@ -18,6 +18,7 @@ export interface ILoadingIndicators { [name: string]: number; }
export interface Env {
TESTNET_ENABLED: boolean;
SIGNET_ENABLED: boolean;
+ REGTEST_ENABLED: boolean;
LIQUID_ENABLED: boolean;
LIQUID_TESTNET_ENABLED: boolean;
BISQ_ENABLED: boolean;
@@ -41,6 +42,7 @@ export interface Env {
const defaultEnv: Env = {
'TESTNET_ENABLED': false,
'SIGNET_ENABLED': false,
+ 'REGTEST_ENABLED': false,
'LIQUID_ENABLED': false,
'LIQUID_TESTNET_ENABLED': false,
'BASE_MODULE': 'mempool',
@@ -136,7 +138,7 @@ export class StateService {
if (this.env.BASE_MODULE !== 'mempool' && this.env.BASE_MODULE !== 'liquid') {
return;
}
- const networkMatches = url.match(/\/(bisq|testnet|liquidtestnet|liquid|signet)/);
+ const networkMatches = url.match(/\/(bisq|testnet|liquidtestnet|liquid|signet|regtest)/);
switch (networkMatches && networkMatches[1]) {
case 'liquid':
if (this.network !== 'liquid') {
@@ -156,6 +158,12 @@ export class StateService {
this.networkChanged$.next('signet');
}
return;
+ case 'regtest':
+ if (this.network !== 'regtest') {
+ this.network = 'regtest';
+ this.networkChanged$.next('regtest');
+ }
+ return;
case 'testnet':
if (this.network !== 'testnet') {
if (this.env.BASE_MODULE === 'liquid') {
diff --git a/frontend/src/resources/regtest-logo.png b/frontend/src/resources/regtest-logo.png
new file mode 120000
index 000000000..15dd20db0
--- /dev/null
+++ b/frontend/src/resources/regtest-logo.png
@@ -0,0 +1 @@
+signet-logo.png
\ No newline at end of file