Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
feat: Allow user to override electrum rpc and modify default one (#222)
Browse files Browse the repository at this point in the history
* feat: Allow user to override electrum rpc and modify default one

* bump: release version to 0.6.4
  • Loading branch information
binarybaron authored Sep 26, 2024
1 parent 3036d96 commit 74b13e9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions release/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unstoppableswap-gui",
"version": "0.6.3",
"version": "0.6.4",
"description": "Graphical User Interface for XMR<>BTC Atomic Swaps",
"main": "./dist/main/main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/main/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import PQueue from 'p-queue';
import pidtree from 'pidtree';
import util from 'util';
import { getPlatform, isTestnet } from 'store/config';
import { getElectrumRpcUrl, getPlatform, isTestnet } from 'store/config';
import { CliLog, isCliLog } from 'models/cliModel';
import { getLogsAndStringsFromRawFileString } from 'utils/parseUtils';
import { store } from 'main/store/mainStore';
Expand Down Expand Up @@ -284,6 +284,7 @@ export async function startRPC() {
'start-daemon',
{
'server-address': `${RPC_BIND_HOST}:${RPC_BIND_PORT}`,
'electrum-rpc': getElectrumRpcUrl(),
},
async (logs) => {
RPC_LOG_EVENT_EMITTER.emit(logs.filter(isCliLog));
Expand Down
17 changes: 17 additions & 0 deletions src/store/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { ExtendedProviderStatus } from 'models/apiModel';

const DEFAULT_MAINNET_ELECTRUM_RPC_URL = 'tcp://blockstream.info:110';
const DEFAULT_TESTNET_ELECTRUM_RPC_URL = 'ssl://testnet.foundation.xyz:50002';

export const isTestnet = () =>
process.env.TESTNET?.toString().toLowerCase() === 'true';

Expand Down Expand Up @@ -49,3 +52,17 @@ export const getPlatform = () => {
return 'linux';
}
};

export function getElectrumRpcUrl(): string {
if (isTestnet()) {
// If running on testnet, return the testnet Electrum RPC URL from environment variable or use the default
return (
process.env.OVERRIDE_TESTNET_ELECTRUM_RPC_URL ??
DEFAULT_TESTNET_ELECTRUM_RPC_URL
);
}
// If running on mainnet, return the mainnet Electrum RPC URL from environment variable or use the default
return (
process.env.OVERRIDE_ELECTRUM_RPC_URL ?? DEFAULT_MAINNET_ELECTRUM_RPC_URL
);
}

0 comments on commit 74b13e9

Please sign in to comment.