Skip to content

Allow using RPC hostnames (wallet-cli) #1149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wallet/wallet-cli-lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::{net::SocketAddr, path::PathBuf};
use std::path::PathBuf;

use clap::Parser;
use common::chain::config::ChainType;
Expand Down Expand Up @@ -42,7 +42,7 @@ pub struct WalletCliArgs {

/// Optional RPC address
#[clap(long)]
pub rpc_address: Option<SocketAddr>,
pub rpc_address: Option<String>,

/// Path to the RPC cookie file. If not set, the value is read from the default cookie file location.
#[clap(long)]
Expand Down
4 changes: 2 additions & 2 deletions wallet/wallet-cli-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod repl;

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

use std::{net::SocketAddr, str::FromStr, sync::Arc};
use std::sync::Arc;

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

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

let rpc_auth = match (rpc_cookie_file, rpc_username, rpc_password) {
Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet-cli-lib/tests/cli_test_framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl CliTestFramework {
network: Network::Regtest,
wallet_file: None,
start_staking: false,
rpc_address: Some(self.rpc_address),
rpc_address: Some(self.rpc_address.to_string()),
rpc_cookie_file: None,
rpc_username: Some(RPC_USERNAME.to_owned()),
rpc_password: Some(RPC_PASSWORD.to_owned()),
Expand Down
5 changes: 2 additions & 3 deletions wallet/wallet-node-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use handles_client::WalletHandlesClientError;
use mempool::MempoolHandle;
use p2p::P2pHandle;
use rpc::RpcAuthData;
use std::net::SocketAddr;

use rpc_client::NodeRpcError;

Expand All @@ -28,10 +27,10 @@ pub mod node_traits;
pub mod rpc_client;

pub async fn make_rpc_client(
remote_socket_address: SocketAddr,
remote_socket_address: String,
rpc_auth: RpcAuthData,
) -> Result<rpc_client::NodeRpcClient, NodeRpcError> {
rpc_client::NodeRpcClient::new(remote_socket_address.to_string(), rpc_auth).await
rpc_client::NodeRpcClient::new(remote_socket_address, rpc_auth).await
}

pub async fn make_handles_client(
Expand Down
3 changes: 2 additions & 1 deletion wallet/wallet-node-client/tests/call_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ async fn node_rpc_communication() {
manager_task_handle,
) = start_subsystems(chain_config.clone(), "127.0.0.1:0".to_string()).await;

let rpc_client = make_rpc_client(rpc_bind_address, RpcAuthData::None).await.unwrap();
let rpc_client =
make_rpc_client(rpc_bind_address.to_string(), RpcAuthData::None).await.unwrap();

test_wallet_node_communication(chain_config, chainstate, rpc_client).await;

Expand Down