Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed Jul 31, 2024
1 parent 241754a commit 76a8786
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
36 changes: 22 additions & 14 deletions applications/minotari_console_wallet/src/automation/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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(_) => {},
Expand Down
4 changes: 1 addition & 3 deletions applications/minotari_console_wallet/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
3 changes: 2 additions & 1 deletion applications/minotari_console_wallet/src/wallet_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
)
}

Expand Down

0 comments on commit 76a8786

Please sign in to comment.