wallet/owner_api: allow owner API port to be configurable ()

This commit is contained in:
Raghav Sood 2019-01-28 18:45:59 +08:00 committed by Antioch Peverell
parent 6d041a949b
commit f2b6100220
2 changed files with 8 additions and 2 deletions

View file

@ -26,7 +26,6 @@ use uuid::Uuid;
use crate::api::TLSConfig;
use crate::core::core;
use crate::core::global;
use crate::keychain;
use crate::error::{Error, ErrorKind};
@ -146,7 +145,7 @@ pub fn owner_api(
) -> Result<(), Error> {
let res = controller::owner_listener(
wallet,
&format!("127.0.0.1:{}", (if global::is_floonet() { "13420" } else { "3420" })),
config.owner_api_listen_addr().as_str(),
g_args.node_api_secret.clone(),
g_args.tls_conf.clone(),
config.owner_api_include_foreign.clone(),

View file

@ -41,6 +41,8 @@ pub struct WalletConfig {
pub api_listen_interface: String,
// The port this wallet will run on
pub api_listen_port: u16,
// The port this wallet's owner API will run on
pub owner_api_listen_port: u16,
/// Location of the secret for basic auth on the Owner API
pub api_secret_path: Option<String>,
/// Location of the node api secret for basic auth on the Grin API
@ -72,6 +74,7 @@ impl Default for WalletConfig {
chain_type: Some(ChainTypes::Mainnet),
api_listen_interface: "127.0.0.1".to_string(),
api_listen_port: 3415,
owner_api_listen_port: 3420,
api_secret_path: Some(".api_secret".to_string()),
node_api_secret_path: Some(".api_secret".to_string()),
check_node_api_http_addr: "http://127.0.0.1:3413".to_string(),
@ -90,6 +93,10 @@ impl WalletConfig {
pub fn api_listen_addr(&self) -> String {
format!("{}:{}", self.api_listen_interface, self.api_listen_port)
}
pub fn owner_api_listen_addr(&self) -> String {
format!("127.0.0.1:{}", self.owner_api_listen_port)
}
}
#[derive(Clone, Debug, PartialEq)]