diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-01-19 21:17:39 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-01-19 21:17:39 +0100 |
commit | a76219b8debfc3f7e932ec9ad996248e431f437e (patch) | |
tree | 938238592a022c39a5ed36edb549423e586db860 | |
parent | e124e05d531af11815e403f3547e167afb80cae6 (diff) |
sort coins by amount first
-rw-r--r-- | src/operations/pay.ts | 4 |
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), ); |