Skip to content
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

use rsplitn for rpc info extraction in case passwords have @ #37

Merged
merged 1 commit into from Oct 17, 2021
Merged

use rsplitn for rpc info extraction in case passwords have @ #37

merged 1 commit into from Oct 17, 2021

Conversation

ghost
Copy link

@ghost ghost commented Oct 15, 2021

  • Noticed I was unable to connect to RPC server due to @ being a character in password, the current behaviour will split n times depending on how many of the @ special character appears and then will fail on URL since there are not two vectors.
  • resolved this by splitting from right side and then swapping the vectors so no other code needed to be modified.

@ghost ghost mentioned this pull request Oct 15, 2021
Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just needs a rustfmt fix and then we can land it.

src/cli.rs Outdated
@@ -45,11 +45,12 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
return Err(());
}
let bitcoind_rpc_info = env::args().skip(1).next().unwrap();
let bitcoind_rpc_info_parts: Vec<&str> = bitcoind_rpc_info.split("@").collect();
let mut bitcoind_rpc_info_parts: Vec<&str> = bitcoind_rpc_info.rsplitn(2,"@").collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and on the line below, rustfmt demands a space after the , in the parameter list.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't know about this tool yet, thanks, should be fixed in the latest commit

src/cli.rs Outdated
if bitcoind_rpc_info_parts.len() != 2 {
println!("ERROR: bad bitcoind RPC URL provided");
return Err(());
}
bitcoind_rpc_info_parts.swap(0,1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe more readable to just change the two lines that access bitcoind_rpc_info_parts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion, I tried this originally but wasn't sure if the reverse index access would be confusing, sounds like this is the better approach.

Copy link
Contributor

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you squash the commits down into one commit to keep the git history clean?

remove swap, fix rustfmt issue

remove return
@ghost
Copy link
Author

ghost commented Oct 17, 2021

Can you squash the commits down into one commit to keep the git history clean?

should be squashed now.

@TheBlueMatt TheBlueMatt merged commit 32bfe68 into lightningdevkit:main Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant