mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-01 19:33:56 +01:00
Add owner_api_listen_interface as hidden configuration field (#714)
This commit is contained in:
+21
-1
@@ -28,6 +28,9 @@ pub struct WalletConfig {
|
||||
pub chain_type: Option<ChainTypes>,
|
||||
/// The port this wallet will run on
|
||||
pub api_listen_port: u16,
|
||||
/// Listen interface for the owner API, should be hidden from config by default
|
||||
#[serde(skip_serializing)]
|
||||
pub owner_api_listen_interface: Option<String>,
|
||||
/// The port this wallet's owner API will run on
|
||||
pub owner_api_listen_port: Option<u16>,
|
||||
/// Location of the secret for basic auth on the Owner API
|
||||
@@ -61,6 +64,7 @@ impl Default for WalletConfig {
|
||||
WalletConfig {
|
||||
chain_type: Some(ChainTypes::Mainnet),
|
||||
api_listen_port: 3415,
|
||||
owner_api_listen_interface: Some(WalletConfig::default_owner_api_listen_interface()),
|
||||
owner_api_listen_port: Some(WalletConfig::default_owner_api_listen_port()),
|
||||
api_secret_path: Some(".owner_api_secret".to_string()),
|
||||
node_api_secret_path: Some(".foreign_api_secret".to_string()),
|
||||
@@ -82,6 +86,11 @@ impl WalletConfig {
|
||||
format!("127.0.0.1:{}", self.api_listen_port)
|
||||
}
|
||||
|
||||
/// Default listener port
|
||||
pub fn default_owner_api_listen_interface() -> String {
|
||||
"127.0.0.1".to_string()
|
||||
}
|
||||
|
||||
/// Default listener port
|
||||
pub fn default_owner_api_listen_port() -> u16 {
|
||||
3420
|
||||
@@ -92,6 +101,13 @@ impl WalletConfig {
|
||||
500_000
|
||||
}
|
||||
|
||||
/// Use value from config file, defaulting to sensible value if missing.
|
||||
pub fn owner_api_listen_interface(&self) -> String {
|
||||
self.owner_api_listen_interface
|
||||
.clone()
|
||||
.unwrap_or_else(|| WalletConfig::default_owner_api_listen_interface())
|
||||
}
|
||||
|
||||
/// Use value from config file, defaulting to sensible value if missing.
|
||||
pub fn owner_api_listen_port(&self) -> u16 {
|
||||
self.owner_api_listen_port
|
||||
@@ -100,7 +116,11 @@ impl WalletConfig {
|
||||
|
||||
/// Owner API listen address
|
||||
pub fn owner_api_listen_addr(&self) -> String {
|
||||
format!("127.0.0.1:{}", self.owner_api_listen_port())
|
||||
format!(
|
||||
"{}:{}",
|
||||
self.owner_api_listen_interface(),
|
||||
self.owner_api_listen_port()
|
||||
)
|
||||
}
|
||||
|
||||
/// Accept fee base
|
||||
|
||||
Reference in New Issue
Block a user