diff options
| author | Adrien Hopkins <[email protected]> | 2022-06-16 12:23:23 -0500 |
|---|---|---|
| committer | Adrien Hopkins <[email protected]> | 2022-06-16 12:23:23 -0500 |
| commit | 51ed4347d0dfcaac16957abf31848e0dd9d86b40 (patch) | |
| tree | cad6b3e196562a170967c0c566f5512c7bbb7753 /routes/lnurl.js | |
| parent | 55d4763146916e7e168bdc0ffd6d97c0d82f8e83 (diff) | |
| download | coinos-server-51ed4347d0dfcaac16957abf31848e0dd9d86b40.tar.gz coinos-server-51ed4347d0dfcaac16957abf31848e0dd9d86b40.zip | |
Whether you can pay takes into account fee deductions
Diffstat (limited to 'routes/lnurl.js')
| -rw-r--r-- | routes/lnurl.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js index 49212330..93d939f9 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -420,13 +420,6 @@ lnurlServer.bindToHook( transaction }); - if (account.balance < amount) { - throw new Error("Insufficient funds"); - } else if (account.balance < amount + conversionFee) { - throw new Error("Insufficient funds for conversion fee"); - } - - // use user's credits to reduce fee, if available let conversionFeeDeduction = Math.min(account.lightning_credits, conversionFee); if (conversionFeeDeduction) { await account.decrement({ lightning_credits: conversionFeeDeduction }, { transaction }); @@ -434,6 +427,12 @@ lnurlServer.bindToHook( conversionFee -= conversionFeeDeduction; } + if (account.balance < amount) { + throw new Error("Insufficient funds"); + } else if (account.balance < amount + conversionFee) { + throw new Error("Insufficient funds for conversion fee"); + } + let fee_payment_id = null; if (conversionFee) { await receiverAccount.increment({ balance: conversionFee }, { transaction }); |
