|
|
@ -556,17 +556,27 @@ impl Command for SendCommand { |
|
|
|
// Transform transaction data into the required format (String -> &str).
|
|
|
|
let tos = send_args.iter().map(|(a, v, m, _)| (a.as_str(), *v, m.clone())).collect::<Vec<_>>(); |
|
|
|
|
|
|
|
let default_fee = DEFAULT_FEE.try_into().unwrap(); |
|
|
|
// Calculate the total fee for all transactions.
|
|
|
|
|
|
|
|
// This assumes that all transactions have the same fee.
|
|
|
|
// If they can have different fees, you need to modify this logic.
|
|
|
|
let total_fee = send_args.iter() |
|
|
|
.filter_map(|(_, _, _, fee)| Some(*fee)) |
|
|
|
.next() |
|
|
|
.unwrap_or(default_fee); |
|
|
|
|
|
|
|
let default_fee: u64 = DEFAULT_FEE.try_into().unwrap();
|
|
|
|
let mut fee_found = false; |
|
|
|
let mut total_fee = default_fee;
|
|
|
|
|
|
|
|
for (_, _, _, fee) in send_args.iter() { |
|
|
|
if *fee != default_fee{ |
|
|
|
total_fee = *fee; |
|
|
|
fee_found = true; |
|
|
|
break;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
println!("Fee used : {:?}", total_fee); |
|
|
|
if fee_found { |
|
|
|
println!("Using custom fee: {:?}", total_fee); |
|
|
|
} else { |
|
|
|
println!("Using default fee: "); |
|
|
|
} |
|
|
|
|
|
|
|
// Execute the transaction and handle the result.
|
|
|
|
match lightclient.do_send(tos, &total_fee) { |
|
|
|