From a76219b8debfc3f7e932ec9ad996248e431f437e Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 19 Jan 2020 21:17:39 +0100 Subject: sort coins by amount first --- src/operations/pay.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/operations/pay.ts') diff --git a/src/operations/pay.ts b/src/operations/pay.ts index c5a344186..b8a63cb11 100644 --- a/src/operations/pay.ts +++ b/src/operations/pay.ts @@ -185,10 +185,12 @@ export function selectPayCoins( } const coinPubs: string[] = []; const coinContributions: AmountJson[] = []; - // Sort by ascending deposit fee and denomPub if deposit fee is the same + // Sort by available amount (descending), deposit fee (ascending) and + // denomPub (ascending) if deposit fee is the same // (to guarantee deterministic results) acis.sort( (o1, o2) => + -Amounts.cmp(o1.availableAmount, o2.availableAmount) || Amounts.cmp(o1.feeDeposit, o2.feeDeposit) || strcmp(o1.denomPub, o2.denomPub), ); -- cgit v1.2.3