-
Notifications
You must be signed in to change notification settings - Fork 57
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
Added Wallet Export Functionality #227
base: master
Are you sure you want to change the base?
Conversation
Thanks for the contribution! Before we can merge this, we need @adirola to sign the Fuel Labs Contributor License Agreement. |
@kayagokalp here is the PR for export functionality |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, just a few nits.
/// Forces export even if it might be unsafe | ||
#[clap(short, long)] | ||
pub force: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like this is used anywhere. What does this mean?
/// Forces export even if it might be unsafe | |
#[clap(short, long)] | |
pub force: bool, |
/// How many accounts to cache by default (Default 10) | ||
#[clap(short, long)] | ||
pub cache_accounts: Option<usize>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use clap to set the default
/// How many accounts to cache by default (Default 10) | |
#[clap(short, long)] | |
pub cache_accounts: Option<usize>, | |
/// The number of accounts to cache | |
#[clap(long, default_value = 10)] | |
pub cache_accounts: usize, |
} | ||
|
||
/// Securely wipes sensitive data from memory | ||
fn secure_wipe(data: &mut [u8]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! We should use zeroize instead to make sure this isn't optimized away by the compiler.
fn test_export_wallet() { | ||
with_tmp_dir_and_wallet(|_dir, wallet_path| { | ||
let result = export_wallet(&wallet_path, TEST_PASSWORD); | ||
assert!(result.is_ok()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be an unwrap
assert!(result.is_ok()); | ||
|
||
if let Ok(phrase) = result { | ||
assert!(!phrase.is_empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should assert that it's the test mnemonic
export command will request the password to unlock the wallet to derive the wallet mnemonic which is rendered on alternamte screen and the buffer is cleared. The derived addresses will be stored in cache.
Linked to PR : #222