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

Cli shared recovery create - ask for threshold if not provided. #9127

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 43 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ crypto_secretbox = { version = "0.1.1", default-features = false }
ctrlc = { version = "3.4.5", default-features = false }
# You need base64&co ? This is the crate you need !
data-encoding = { version = "2.6.0", default-features = false }
dialoguer = { version = "0.11.0", default-features = false }
digest = { version = "0.10.7", default-features = false }
dirs = { version = "5.0.1", default-features = false }
ed25519-dalek = { version = "2.1.1", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ libparsec_platform_ipc = { workspace = true }

anyhow = { workspace = true }
clap = { workspace = true, features = ["default", "derive", "env"] }
dialoguer = { workspace = true }
env_logger = { workspace = true, features = ["auto-color", "humantime", "regex"] }
log = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
Expand Down
15 changes: 13 additions & 2 deletions cli/src/commands/shared_recovery/create.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, num::NonZeroU8};

use dialoguer::Input;
use libparsec::{UserID, UserProfile};

use crate::utils::{load_client, start_spinner};
Expand All @@ -20,8 +21,8 @@ crate::clap_parser_with_shared_opts_builder!(
#[arg(short, long, requires = "recipients", num_args = 1..=255)]
weights: Option<Vec<NonZeroU8>>,
/// Threshold number of shares required to proceed with recovery.
#[arg(short, long)]
threshold: NonZeroU8,
#[arg(short, long, requires = "recipients")]
threshold: Option<NonZeroU8>,
}
);

Expand Down Expand Up @@ -84,6 +85,16 @@ pub async fn main(shamir_setup: Args) -> anyhow::Result<()> {
.collect()
};

let threshold = if let Some(t) = threshold {
t
} else {
Input::<NonZeroU8>::new()
.with_prompt(format!(
"Choose a threshold between 1 and {}\nThe threshold is the minimum number of recipients that one must gather to recover the account",
per_recipient_shares.len()
)) .interact_text()?
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a blocking sync call in an async function, we should at least acknowledge it with a comment

};

client
.setup_shamir_recovery(per_recipient_shares, threshold)
.await?;
Expand Down
Loading