Skip to content

Commit

Permalink
Slightly better ux
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jun 8, 2024
1 parent dab99f9 commit 14f80d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ from the channels.

```bash
cargo install mutiny-data-recovery
mutiny-data-recovery --seed "your seed here"
mutiny-data-recovery
```
4 changes: 0 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use bip39::Mnemonic;
use clap::Parser;

#[derive(Parser, Debug, Clone)]
#[command(version, author, about)]
/// A tool for recovering a mutiny wallet from a corrupted state.
pub struct Config {
/// Your mnemonic seed
#[clap(short, long)]
pub seed: Mnemonic,
/// URL for mutiny authentication
#[clap(default_value = "https://auth.mutinywallet.com", short, long)]
pub auth_url: String,
Expand Down
23 changes: 20 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use mutiny_core::bitcoin::Network;
use mutiny_core::lnurlauth::AuthManager;
use mutiny_core::logging::MutinyLogger;
use mutiny_core::vss::MutinyVssClient;
use std::io::Write;
use std::str::FromStr;
use std::sync::Arc;

mod config;
Expand All @@ -14,8 +16,23 @@ mod config;
async fn main() -> anyhow::Result<()> {
let logger = Arc::new(MutinyLogger::default());
let config: Config = Config::parse();
let seed = config.seed.to_seed("");
let xprivkey = ExtendedPrivKey::new_master(Network::Bitcoin, &seed).unwrap();

// Create a mutable string to store the user input
let mut input = String::new();

// Prompt the user for input
print!("Enter your mnemonic seed: ");
// Flush stdout to ensure the prompt is displayed before input is read
std::io::stdout().flush()?;

// Read the input from stdin and handle potential errors
std::io::stdin()
.read_line(&mut input)
.expect("Failed to read line");

let seed = bip39::Mnemonic::from_str(input.trim())?;

let xprivkey = ExtendedPrivKey::new_master(Network::Bitcoin, &seed.to_seed("")).unwrap();

let auth_manager = AuthManager::new(xprivkey).unwrap();

Expand Down Expand Up @@ -67,7 +84,7 @@ async fn main() -> anyhow::Result<()> {
// put the new objects back
vss.put_objects(new_objects).await?;

println!("Done! Open Mutiny Wallet and your channels should force close.");
println!("\nDone! Open Mutiny Wallet and your channels should force close and be recoverable on-chain in 3-14 days.");

Ok(())
}

0 comments on commit 14f80d9

Please sign in to comment.