aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-01-13 22:32:13 -0800
committerAdam Soltys <[email protected]>2021-01-13 22:32:13 -0800
commitd03dad4d85ccd107068719c4b68cbd6a255864f6 (patch)
tree224a1ad8caa3f2abdab3d35b8a564cdf4c98c233 /lib
parentb605dd257984d3384c680de2cf64e44bfd3484ca (diff)
downloadcoinos-server-d03dad4d85ccd107068719c4b68cbd6a255864f6.tar.gz
coinos-server-d03dad4d85ccd107068719c4b68cbd6a255864f6.zip
use decrement operation in lightning send
Diffstat (limited to 'lib')
-rw-r--r--lib/send.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/send.js b/lib/send.js
index 733c3cfb..4e00f54a 100644
--- a/lib/send.js
+++ b/lib/send.js
@@ -29,6 +29,8 @@ send = async (amount, memo, hash, user) => {
}
let error, fee, total, preimage;
+ await account.decrement({ balance: amount }, { transaction });
+ await account.reload({ transaction });
if (config.lna.clightning) {
let m = await lna.pay(hash);
@@ -66,9 +68,8 @@ send = async (amount, memo, hash, user) => {
total = parseInt(total);
fee = parseInt(fee);
- await new Promise((resolve) => setTimeout(resolve, 5000));
- account.balance -= total;
- await account.save({ transaction });
+ await account.decrement({ balance: fee }, { transaction });
+ await account.reload({ transaction });
payment = await db.Payment.create(
{