aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/operations/pay.ts4
1 files changed, 3 insertions, 1 deletions
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),
);