Skip to content

Commit

Permalink
Have wallet-display show earn amount from coinswap
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-belcher committed Jan 30, 2022
1 parent 365b869 commit 281eb2e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,17 @@ pub fn display_wallet_balance(wallet_file_name: &PathBuf, long_form: Option<bool
println!("= incomplete coinswaps =");
for (hashvalue, (utxo_incoming_swapcoins, utxo_outgoing_swapcoins)) in incomplete_coinswaps
{
let balance: Amount = utxo_incoming_swapcoins
let incoming_swapcoins_balance: Amount = utxo_incoming_swapcoins
.iter()
.map(|(l, i)| (l, (*i as &dyn SwapCoin)))
.chain(
utxo_outgoing_swapcoins
.iter()
.map(|(l, o)| (l, (*o as &dyn SwapCoin))),
)
.fold(Amount::ZERO, |acc, us| acc + us.0.amount);
let outgoing_swapcoins_balance: Amount = utxo_outgoing_swapcoins
.iter()
.fold(Amount::ZERO, |acc, us| acc + us.0.amount);

println!(
"{:16} {:8} {:8} {:<15} {:<7} value",
"coin", "type", "preimage", "locktime/blocks", "conf",
);

for ((utxo, swapcoin), contract_type) in utxo_incoming_swapcoins
.iter()
.map(|(l, i)| (l, (*i as &dyn SwapCoin)))
Expand Down Expand Up @@ -240,9 +237,11 @@ pub fn display_wallet_balance(wallet_file_name: &PathBuf, long_form: Option<bool
);
}
println!(
"hashvalue = {}\ntotal balance = {}",
&hashvalue.to_hex()[..],
balance
"outgoing balance = {}\namount earned if coinswap successful = {}\nhashvalue = {}",
outgoing_swapcoins_balance,
(incoming_swapcoins_balance.to_signed().unwrap()
- outgoing_swapcoins_balance.to_signed().unwrap()),
&hashvalue.to_hex()[..]
);
}
}
Expand Down

0 comments on commit 281eb2e

Please sign in to comment.