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

fix(wallet): add default value for wait stage #4089

Merged
merged 3 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 2 additions & 14 deletions applications/tari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use std::{
fs::File,
io::{LineWriter, Write},
str::FromStr,
time::{Duration, Instant},
};

Expand Down Expand Up @@ -52,6 +51,7 @@ use tari_wallet::{
key_manager_service::KeyManagerInterface,
output_manager_service::handle::OutputManagerHandle,
transaction_service::handle::{TransactionEvent, TransactionServiceHandle},
TransactionStage,
WalletConfig,
WalletSqlite,
};
Expand Down Expand Up @@ -95,17 +95,6 @@ pub enum WalletCommand {
RevalidateWalletDb,
}

#[derive(Debug, EnumString, PartialEq, Clone, Copy)]
pub enum TransactionStage {
Initiated,
DirectSendOrSaf,
Negotiated,
Broadcast,
MinedUnconfirmed,
Mined,
TimedOut,
}

#[derive(Debug)]
pub struct SentTransaction {}

Expand Down Expand Up @@ -630,8 +619,7 @@ pub async fn command_runner(
commands: Vec<ParsedCommand>,
wallet: WalletSqlite,
) -> Result<(), CommandError> {
let wait_stage =
TransactionStage::from_str(&config.command_send_wait_stage).map_err(|e| CommandError::Config(e.to_string()))?;
let wait_stage = config.command_send_wait_stage;

let mut transaction_service = wallet.transaction_service.clone();
let mut output_service = wallet.output_manager_service.clone();
Expand Down
16 changes: 14 additions & 2 deletions base_layer/wallet/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use std::{
};

use serde::{Deserialize, Serialize};
use strum::EnumString;
use tari_common::{
configuration::{serializers, Network, StringList},
SubConfigPath,
Expand Down Expand Up @@ -63,7 +64,7 @@ pub struct WalletConfig {
pub contacts_online_ping_window: usize,
#[serde(with = "serializers::seconds")]
pub command_send_wait_timeout: Duration,
pub command_send_wait_stage: String,
pub command_send_wait_stage: TransactionStage,
pub notify_file: Option<PathBuf>,
pub grpc_address: Option<Multiaddr>,
pub custom_base_node: Option<String>,
Expand Down Expand Up @@ -93,7 +94,7 @@ impl Default for WalletConfig {
password: None,
contacts_auto_ping_interval: Duration::from_secs(30),
contacts_online_ping_window: 30,
command_send_wait_stage: String::new(),
command_send_wait_stage: TransactionStage::Broadcast,
command_send_wait_timeout: Duration::from_secs(300),
notify_file: None,
grpc_address: None,
Expand Down Expand Up @@ -125,3 +126,14 @@ impl WalletConfig {
self.p2p.set_base_path(self.data_dir.as_path());
}
}

#[derive(Debug, EnumString, PartialEq, Clone, Copy, Serialize, Deserialize)]
pub enum TransactionStage {
Initiated,
DirectSendOrSaf,
Negotiated,
Broadcast,
MinedUnconfirmed,
Mined,
TimedOut,
}
2 changes: 1 addition & 1 deletion base_layer/wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub mod key_manager_service;
pub mod schema;
pub mod utxo_scanner_service;

pub use config::WalletConfig;
pub use config::{TransactionStage, WalletConfig};
pub use wallet::Wallet;

use crate::{
Expand Down