Bubble init_send_tx error instead of unwrapping (#600)

Fixes #582
This commit is contained in:
trevyn 2021-04-07 18:24:16 +04:00 committed by GitHub
parent e9e67884d6
commit 5189de5a0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,6 @@
use crate::api::TLSConfig; use crate::api::TLSConfig;
use crate::apiwallet::{try_slatepack_sync_workflow, Owner}; use crate::apiwallet::{try_slatepack_sync_workflow, Owner};
use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME}; use crate::config::{TorConfig, WalletConfig, WALLET_CONFIG_FILE_NAME};
use crate::core::core::FeeFields;
use crate::core::{core, global}; use crate::core::{core, global};
use crate::error::{Error, ErrorKind}; use crate::error::{Error, ErrorKind};
use crate::impls::PathToSlatepack; use crate::impls::PathToSlatepack;
@ -278,7 +277,7 @@ where
let mut slate = Slate::blank(2, false); let mut slate = Slate::blank(2, false);
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| { controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
if args.estimate_selection_strategies { if args.estimate_selection_strategies {
let strategies: Vec<(&str, u64, FeeFields)> = vec!["smallest", "all"] let strategies = vec!["smallest", "all"]
.into_iter() .into_iter()
.map(|strategy| { .map(|strategy| {
let init_args = InitTxArgs { let init_args = InitTxArgs {
@ -291,10 +290,10 @@ where
estimate_only: Some(true), estimate_only: Some(true),
..Default::default() ..Default::default()
}; };
let slate = api.init_send_tx(m, init_args).unwrap(); let slate = api.init_send_tx(m, init_args)?;
(strategy, slate.amount, slate.fee_fields) Ok((strategy, slate.amount, slate.fee_fields))
}) })
.collect(); .collect::<Result<Vec<_>, grin_wallet_libwallet::Error>>()?;
display::estimate(args.amount, strategies, dark_scheme); display::estimate(args.amount, strategies, dark_scheme);
return Ok(()); return Ok(());
} else { } else {