Skip to content

Commit 583cfb1

Browse files
committed
Make Electrum panel optional
1 parent 47e70ef commit 583cfb1

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

.env.local.sample

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# bitcoind config
1+
# ===== bitcoind config =====
22
RPC_USER=username
33
RPC_PASSWORD=password
4-
# BITCOIND_HOST should be your service name for your bitcoind Docker container
4+
# BITCOIND_HOST should be your service name for your bitcoind Docker container
55
BITCOIND_HOST=bitcoind
66
BITCOIND_PORT=8332
7-
# ELECTRUM_HOST should be your service name for your Electrum Server (e.g. electrs) Docker container
7+
8+
# ===== Electrum config =====
9+
# Set ENABLE_ELECTRUM_PANEL to TRUE if you would like to show Electrum panel.
10+
ENABLE_ELECTRUM_PANEL=TRUE
11+
# ELECTRUM_HOST should be your service name for your Electrum Server (e.g. electrs) Docker container
812
ELECTRUM_HOST=electrs
913
ELECTRUM_PORT=50001

pages/index.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export async function getServerSideProps() {
3939
connectionInCount: 0,
4040
connectionOutCount: 0,
4141
enableElectrumPanel: process.env.ENABLE_ELECTRUM_PANEL === 'TRUE',
42-
electrumHost: process.env.ELECTRUM_HOST,
43-
electrumPort: process.env.ELECTRUM_PORT,
42+
electrumHost: '',
43+
electrumPort: 0,
4444
electrumVersion: null,
4545
electrumBlockHeight: null,
4646
};
@@ -99,20 +99,27 @@ export async function getServerSideProps() {
9999
console.error('Error fetching mempool info:', error);
100100
}
101101

102-
try {
103-
const electrumVersion = await getElectrumVersion();
104-
props.electrumVersion = electrumVersion;
105-
} catch (error) {
106-
console.error('Error fetching Electrum version:', error);
107-
}
102+
if (props.enableElectrumPanel) {
108103

109-
try {
110-
const electrumBlockHeight = await getElectrumBlockHeight();
111-
props.electrumBlockHeight = electrumBlockHeight;
112-
} catch (error) {
113-
console.error('Error fetching Electrum block height:', error);
104+
props.electrumHost = String(process.env.ELECTRUM_HOST);
105+
props.electrumPort = Number(process.env.ELECTRUM_PORT);
106+
107+
try {
108+
const electrumVersion = await getElectrumVersion();
109+
props.electrumVersion = electrumVersion;
110+
} catch (error) {
111+
console.error('Error fetching Electrum version:', error);
112+
}
113+
114+
try {
115+
const electrumBlockHeight = await getElectrumBlockHeight();
116+
props.electrumBlockHeight = electrumBlockHeight;
117+
} catch (error) {
118+
console.error('Error fetching Electrum block height:', error);
119+
}
114120
}
115121

122+
116123
return { props };
117124
}
118125

@@ -155,7 +162,7 @@ const BlockInfo: React.FC<any> = (props) => {
155162

156163
<NodePanel data={props}></NodePanel>
157164

158-
<ElectrumPanel data={props}></ElectrumPanel>
165+
{ enableElectrumPanel && <ElectrumPanel data={props}></ElectrumPanel> }
159166

160167
</div>
161168
</div>

0 commit comments

Comments
 (0)