aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/operations/pay.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/operations/pay.ts b/src/operations/pay.ts
index 9a8017e4e..f3468ae46 100644
--- a/src/operations/pay.ts
+++ b/src/operations/pay.ts
@@ -234,11 +234,17 @@ export function selectPayCoins(
).amount;
if (Amounts.cmp(amountActualAvailable, amountPayRemaining) > 0) {
- // Partial spending
+ // Partial spending, as the coin is worth more than the remaining
+ // amount to pay.
coinSpend = Amounts.add(amountPayRemaining, depositFeeSpend).amount;
+ // Make sure we contribute at least the deposit fee, otherwise
+ // contributing this coin would cause a loss for the merchant.
+ if (Amounts.cmp(coinSpend, aci.feeDeposit) < 0) {
+ coinSpend = aci.feeDeposit;
+ }
amountPayRemaining = Amounts.getZero(currency);
} else {
- // Spend the full remaining amount
+ // Spend the full remaining amount on the coin
coinSpend = aci.availableAmount;
amountPayRemaining = Amounts.add(amountPayRemaining, depositFeeSpend)
.amount;