sort coins by amount first

This commit is contained in:
Florian Dold 2020-01-19 21:17:39 +01:00
parent e124e05d53
commit a76219b8de
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -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),
);