Skip to content

Commit

Permalink
Feat: Unix sockets for Electrum RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
junderw committed Sep 30, 2023
1 parent 09a11b1 commit 4339a51
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 61 deletions.
1 change: 1 addition & 0 deletions electrs-start-liquid
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ do
-- \
--network liquid \
--http-socket-file "${HOME}/socket/esplora-liquid-mainnet" \
--rpc-socket-file "${HOME}/socket/electrum-liquid-mainnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--asset-db-path "${HOME}/asset_registry_db" \
--daemon-dir "${HOME}" \
Expand Down
1 change: 1 addition & 0 deletions electrs-start-liquidtestnet
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ do
-- \
--network liquidtestnet \
--http-socket-file "${HOME}/socket/esplora-liquid-testnet" \
--rpc-socket-file "${HOME}/socket/electrum-liquid-testnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--asset-db-path "${HOME}/asset_registry_testnet_db" \
--daemon-dir "${HOME}" \
Expand Down
1 change: 1 addition & 0 deletions electrs-start-mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ do
--bin electrs \
-- \
--http-socket-file "${HOME}/socket/esplora-bitcoin-mainnet" \
--rpc-socket-file "${HOME}/socket/electrum-bitcoin-mainnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \
Expand Down
1 change: 1 addition & 0 deletions electrs-start-signet
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ do
-- \
--network signet \
--http-socket-file "${HOME}/socket/esplora-bitcoin-signet" \
--rpc-socket-file "${HOME}/socket/electrum-bitcoin-signet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \
Expand Down
1 change: 1 addition & 0 deletions electrs-start-testnet
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ do
-- \
--network testnet \
--http-socket-file "${HOME}/socket/esplora-bitcoin-testnet" \
--rpc-socket-file "${HOME}/socket/electrum-bitcoin-testnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \
Expand Down
11 changes: 11 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct Config {
pub electrum_rpc_addr: SocketAddr,
pub http_addr: SocketAddr,
pub http_socket_file: Option<PathBuf>,
pub rpc_socket_file: Option<PathBuf>,
pub monitoring_addr: SocketAddr,
pub jsonrpc_import: bool,
pub light_mode: bool,
Expand Down Expand Up @@ -243,6 +244,14 @@ impl Config {
.takes_value(true),
);

#[cfg(unix)]
let args = args.arg(
Arg::with_name("rpc_socket_file")
.long("rpc-socket-file")
.help("Electrum RPC 'unix socket file' to listen on (default disabled, enabling this ignores the electrum_rpc_addr arg)")
.takes_value(true),
);

#[cfg(feature = "liquid")]
let args = args
.arg(
Expand Down Expand Up @@ -384,6 +393,7 @@ impl Config {
);

let http_socket_file: Option<PathBuf> = m.value_of("http_socket_file").map(PathBuf::from);
let rpc_socket_file: Option<PathBuf> = m.value_of("rpc_socket_file").map(PathBuf::from);
let monitoring_addr: SocketAddr = str_to_socketaddr(
m.value_of("monitoring_addr")
.unwrap_or(&format!("127.0.0.1:{}", default_monitoring_port)),
Expand Down Expand Up @@ -452,6 +462,7 @@ impl Config {
electrum_banner,
http_addr,
http_socket_file,
rpc_socket_file,
monitoring_addr,
mempool_backlog_stats_ttl: value_t_or_exit!(m, "mempool_backlog_stats_ttl", u64),
mempool_recent_txs_size: value_t_or_exit!(m, "mempool_recent_txs_size", usize),
Expand Down
Loading

0 comments on commit 4339a51

Please sign in to comment.