diff --git a/applications/minotari_console_wallet/src/automation/commands.rs b/applications/minotari_console_wallet/src/automation/commands.rs index 3ca689fed1..5827e4a2a7 100644 --- a/applications/minotari_console_wallet/src/automation/commands.rs +++ b/applications/minotari_console_wallet/src/automation/commands.rs @@ -1264,22 +1264,28 @@ pub async fn command_runner( println!(); }, PreMineSpendBackupUtxo(args) => { - let commitment = if let Ok(val) = Commitment::from_hex(&args.commitment) { - val - } else { - eprintln!("\nError: Invalid 'commitment' provided!\n"); - continue; - }; - let hash = if let Ok(val) = FixedHash::from_hex(&args.output_hash) { - val - } else { - eprintln!("\nError: Invalid 'output_hash' provided!\n"); - continue; + match key_manager_service.get_wallet_type().await { + WalletType::Ledger(_) => {}, + _ => { + eprintln!("\nError: Wallet type must be 'Ledger' to spend pre-mine outputs!\n"); + break; + }, + } + + let embedded_output = match get_embedded_pre_mine_outputs(vec![args.output_index]) { + Ok(outputs) => outputs[0].clone(), + Err(e) => { + eprintln!("\nError: {}\n", e); + break; + }, }; + let commitment = embedded_output.commitment.clone(); + let output_hash = embedded_output.hash(); + match spend_backup_pre_mine_utxo( transaction_service.clone(), args.fee_per_gram, - hash, + output_hash, commitment.clone(), args.recipient_address, ) @@ -1290,10 +1296,12 @@ pub async fn command_runner( println!("Spend utxo: {} with tx_id: {}", commitment.to_hex(), tx_id); println!(); }, - Err(e) => eprintln!("\nError:Spent pre-mine transaction error! {}\n", e), + Err(e) => { + eprintln!("\nError: Spent pre-mine transaction error! {}\n", e); + break; + }, } }, - PreMineCreatePartyDetails(args) => { PreMineSpendPartyDetails(args) => { match key_manager_service.get_wallet_type().await { WalletType::Ledger(_) => {}, diff --git a/applications/minotari_console_wallet/src/cli.rs b/applications/minotari_console_wallet/src/cli.rs index 4432e4ea13..22db41468c 100644 --- a/applications/minotari_console_wallet/src/cli.rs +++ b/applications/minotari_console_wallet/src/cli.rs @@ -241,9 +241,7 @@ pub struct PreMineSpendBackupUtxoArgs { #[clap(long)] pub fee_per_gram: MicroMinotari, #[clap(long)] - pub commitment: String, - #[clap(long)] - pub output_hash: String, + pub output_index: usize, #[clap(long)] pub recipient_address: TariAddress, } diff --git a/applications/minotari_console_wallet/src/wallet_modes.rs b/applications/minotari_console_wallet/src/wallet_modes.rs index 2f93972a68..a4fb0277ef 100644 --- a/applications/minotari_console_wallet/src/wallet_modes.rs +++ b/applications/minotari_console_wallet/src/wallet_modes.rs @@ -177,7 +177,8 @@ fn force_exit_for_pre_mine_commands(command: &CliCommands) -> bool { CliCommands::PreMineSpendEncumberAggregateUtxo(_) | CliCommands::PreMineSpendAggregateTransaction(_) | CliCommands::PreMineSpendPartyDetails(_) | - CliCommands::PreMineSpendInputOutputSigs(_) + CliCommands::PreMineSpendInputOutputSigs(_) | + CliCommands::PreMineSpendBackupUtxo(_) ) }