Skip to content

Commit 4ee887b

Browse files
Merge pull request #1149 from mintlayer/rpc_connect_hostname
Allow using RPC hostnames (wallet-cli)
2 parents 78093bd + 8cdf529 commit 4ee887b

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

wallet/wallet-cli-lib/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
use std::{net::SocketAddr, path::PathBuf};
16+
use std::path::PathBuf;
1717

1818
use clap::Parser;
1919
use common::chain::config::ChainType;
@@ -42,7 +42,7 @@ pub struct WalletCliArgs {
4242

4343
/// Optional RPC address
4444
#[clap(long)]
45-
pub rpc_address: Option<SocketAddr>,
45+
pub rpc_address: Option<String>,
4646

4747
/// Path to the RPC cookie file. If not set, the value is read from the default cookie file location.
4848
#[clap(long)]

wallet/wallet-cli-lib/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod repl;
2222

2323
type CliController = wallet_controller::RpcController<wallet::wallet_events::WalletEventsNoOp>;
2424

25-
use std::{net::SocketAddr, str::FromStr, sync::Arc};
25+
use std::sync::Arc;
2626

2727
use cli_event_loop::Event;
2828
use commands::WalletCommand;
@@ -80,7 +80,7 @@ pub async fn run(
8080
.unwrap_or_else(|| Arc::new(common::chain::config::Builder::new(chain_type).build()));
8181

8282
// TODO: Use the constant with the node
83-
let default_http_rpc_addr = || SocketAddr::from_str("127.0.0.1:3030").expect("Can't fail");
83+
let default_http_rpc_addr = || "127.0.0.1:3030".to_owned();
8484
let rpc_address = rpc_address.unwrap_or_else(default_http_rpc_addr);
8585

8686
let rpc_auth = match (rpc_cookie_file, rpc_username, rpc_password) {

wallet/wallet-cli-lib/tests/cli_test_framework.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl CliTestFramework {
310310
network: Network::Regtest,
311311
wallet_file: None,
312312
start_staking: false,
313-
rpc_address: Some(self.rpc_address),
313+
rpc_address: Some(self.rpc_address.to_string()),
314314
rpc_cookie_file: None,
315315
rpc_username: Some(RPC_USERNAME.to_owned()),
316316
rpc_password: Some(RPC_PASSWORD.to_owned()),

wallet/wallet-node-client/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use handles_client::WalletHandlesClientError;
1919
use mempool::MempoolHandle;
2020
use p2p::P2pHandle;
2121
use rpc::RpcAuthData;
22-
use std::net::SocketAddr;
2322

2423
use rpc_client::NodeRpcError;
2524

@@ -28,10 +27,10 @@ pub mod node_traits;
2827
pub mod rpc_client;
2928

3029
pub async fn make_rpc_client(
31-
remote_socket_address: SocketAddr,
30+
remote_socket_address: String,
3231
rpc_auth: RpcAuthData,
3332
) -> Result<rpc_client::NodeRpcClient, NodeRpcError> {
34-
rpc_client::NodeRpcClient::new(remote_socket_address.to_string(), rpc_auth).await
33+
rpc_client::NodeRpcClient::new(remote_socket_address, rpc_auth).await
3534
}
3635

3736
pub async fn make_handles_client(

wallet/wallet-node-client/tests/call_tests.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ async fn node_rpc_communication() {
237237
manager_task_handle,
238238
) = start_subsystems(chain_config.clone(), "127.0.0.1:0".to_string()).await;
239239

240-
let rpc_client = make_rpc_client(rpc_bind_address, RpcAuthData::None).await.unwrap();
240+
let rpc_client =
241+
make_rpc_client(rpc_bind_address.to_string(), RpcAuthData::None).await.unwrap();
241242

242243
test_wallet_node_communication(chain_config, chainstate, rpc_client).await;
243244

0 commit comments

Comments
 (0)