diff --git a/.env.example b/.env.example index 132d859..eeacfd3 100644 --- a/.env.example +++ b/.env.example @@ -106,6 +106,18 @@ MONERO_MIN_INCOMING_ATOMIC=10000000 # 0.00001 XMR (~half a USD cent at that mome BITCOIN_CONFIRMATION_TIERS='[{"upToTotalFiat":"30","minConfirmations":0},{"upToTotalFiat":"100","minConfirmations":1},{"upToTotalFiat":"300","minConfirmations":3},{"minConfirmations":6}]' BITCOIN_MIN_INCOMING_ATOMIC=7 # 0.00000007 BTC (~half a USD cent at that moment) +ELECTRUM_VERSION=4.8.1 +ELECTRUM_NETWORK=testnet +ELECTRUM_SERVER=electrum.blockstream.info:60002:s +ELECTRUM_DAEMON_HOST=electrum-daemon +ELECTRUM_DAEMON_PORT=7777 +ELECTRUM_DAEMON_RPC_USER=electrum +ELECTRUM_DAEMON_RPC_PASSWORD=change-me +ELECTRUM_DAEMON_RPC_TIMEOUT_MS=10000 +ELECTRUM_WALLET_DIR=./electrum-daemon/wallet +ELECTRUM_WALLET_NAME=shop +ELECTRUM_WALLET_PASSWORD=change-me + SIMPLEX_CHAT_VERSION=v6.5.6 SIMPLEX_WS_URL=ws://simplex-cli:5225 SIMPLEX_BOT_DISPLAY_NAME=NullCartBot diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index b844f67..afe3c0f 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,6 +10,8 @@ import { PostgresConfig, ShopSettingsConfig } from '../types/Config'; +import { ElectrumNetwork } from '../types/ElectrumNetwork'; +import { ElectrumWalletConfig } from '../types/ElectrumWalletConfig'; import { MoneroNetwork } from '../types/MoneroNetwork'; import { MoneroWalletConfig } from '../types/MoneroWalletConfig'; import { ConfirmationTier } from '../types/ConfirmationTier'; @@ -210,6 +212,15 @@ export const getMoneroWalletConfig = (): MoneroWalletConfig => ({ rpcTimeoutMs: envInt('MONERO_WALLET_RPC_TIMEOUT_MS') }); +export const getElectrumWalletConfig = (): ElectrumWalletConfig => ({ + network: env('ELECTRUM_NETWORK') as ElectrumNetwork, + server: env('ELECTRUM_SERVER'), + rpcUrl: `http://${env('ELECTRUM_DAEMON_HOST')}:${envInt('ELECTRUM_DAEMON_PORT')}`, + username: env('ELECTRUM_DAEMON_RPC_USER'), + password: env('ELECTRUM_DAEMON_RPC_PASSWORD'), + rpcTimeoutMs: envInt('ELECTRUM_DAEMON_RPC_TIMEOUT_MS') +}); + export const getSimplexConfig = (): SimplexConfig => ({ wsUrl: env('SIMPLEX_WS_URL'), botDisplayName: env('SIMPLEX_BOT_DISPLAY_NAME') @@ -226,5 +237,6 @@ export default () => ({ order: getOrderConfig(), invoice: getInvoiceConfig(), moneroWallet: getMoneroWalletConfig(), + electrumWallet: getElectrumWalletConfig(), simplex: getSimplexConfig() }); diff --git a/backend/src/config/validate.ts b/backend/src/config/validate.ts index ea802cf..438d16e 100644 --- a/backend/src/config/validate.ts +++ b/backend/src/config/validate.ts @@ -5,6 +5,7 @@ import { ShopFiatCurrency } from '../types/ShopFiatCurrency'; import { IsBase64 } from '../validation/decorators/isBase64'; import { IsConfirmationTiers } from '../validation/decorators/isConfirmationTiers'; import { IsEnabledPaymentMethods } from '../validation/decorators/isEnabledPaymentMethods'; +import { ElectrumNetwork } from '../types/ElectrumNetwork'; import { MoneroNetwork } from '../types/MoneroNetwork'; class EnvironmentVariables { @@ -342,6 +343,37 @@ class EnvironmentVariables { @Min(1000) MONERO_WALLET_RPC_TIMEOUT_MS: number; + @IsNotEmpty() + @IsEnum(ElectrumNetwork) + ELECTRUM_NETWORK: ElectrumNetwork; + + @IsNotEmpty() + @IsString() + ELECTRUM_SERVER: string; + + @IsNotEmpty() + @IsString() + ELECTRUM_DAEMON_HOST: string; + + @IsNotEmpty() + @IsNumber() + @Min(1) + @Max(65535) + ELECTRUM_DAEMON_PORT: number; + + @IsNotEmpty() + @IsString() + ELECTRUM_DAEMON_RPC_USER: string; + + @IsNotEmpty() + @IsString() + ELECTRUM_DAEMON_RPC_PASSWORD: string; + + @IsNotEmpty() + @IsNumber() + @Min(1000) + ELECTRUM_DAEMON_RPC_TIMEOUT_MS: number; + @IsNotEmpty() @IsString() SIMPLEX_WS_URL: string; diff --git a/backend/src/types/Config.ts b/backend/src/types/Config.ts index 66f5584..485891c 100644 --- a/backend/src/types/Config.ts +++ b/backend/src/types/Config.ts @@ -1,4 +1,5 @@ import { ConfirmationTier } from './ConfirmationTier'; +import { ElectrumWalletConfig } from './ElectrumWalletConfig'; import { MoneroWalletConfig } from './MoneroWalletConfig'; import { NodeEnv } from './NodeEnv'; import { PaymentMethod } from '../modules/payment/types/PaymentMethod'; @@ -122,5 +123,6 @@ export interface Config { order: OrderConfig; invoice: InvoiceConfig; moneroWallet: MoneroWalletConfig; + electrumWallet: ElectrumWalletConfig; simplex: SimplexConfig; } diff --git a/backend/src/types/ElectrumNetwork.ts b/backend/src/types/ElectrumNetwork.ts new file mode 100644 index 0000000..7a5d863 --- /dev/null +++ b/backend/src/types/ElectrumNetwork.ts @@ -0,0 +1,4 @@ +export enum ElectrumNetwork { + Mainnet = 'mainnet', + Testnet = 'testnet' +} diff --git a/backend/src/types/ElectrumWalletConfig.ts b/backend/src/types/ElectrumWalletConfig.ts new file mode 100644 index 0000000..da80fe4 --- /dev/null +++ b/backend/src/types/ElectrumWalletConfig.ts @@ -0,0 +1,10 @@ +import { ElectrumNetwork } from './ElectrumNetwork'; + +export interface ElectrumWalletConfig { + network: ElectrumNetwork; + server: string; + rpcUrl: string; + username: string; + password: string; + rpcTimeoutMs: number; +}