fixing issue where wallet outputs become spent when api server doesn't exist (#242)

This commit is contained in:
Yeastplume 2017-11-08 00:44:20 +00:00 committed by GitHub
parent 024a016bce
commit 5b47da907f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -96,7 +96,11 @@ pub fn refresh_outputs(config: &WalletConfig, keychain: &Keychain) -> Result<(),
Ok(outputs) => for out in outputs {
api_outputs.insert(out.commit, out);
},
Err(_) => {}
Err(e) => {
// if we got anything other than 200 back from server, don't attempt to refresh the wallet
// data after
return Err(Error::Node(e));
}
};
// now for each commit, find the output in the wallet and

View file

@ -19,7 +19,7 @@ use types::{WalletConfig, WalletData};
pub fn show_info(config: &WalletConfig, keychain: &Keychain) {
let root_key_id = keychain.root_key_id();
let _ = checker::refresh_outputs(&config, &keychain);
let result = checker::refresh_outputs(&config, &keychain);
// just read the wallet here, no need for a write lock
let _ = WalletData::read_wallet(&config.data_file_dir, |wallet_data| {
@ -56,4 +56,8 @@ pub fn show_info(config: &WalletConfig, keychain: &Keychain) {
);
}
});
if let Err(e) = result {
println!("WARNING - Showing local data only - Wallet was unable to contact a node to update and verify the outputs shown here.");
}
}