aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2018-11-29 11:29:04 -0800
committerAdam Soltys <[email protected]>2018-11-29 11:29:04 -0800
commit075361f1b32f52b220814aae0355c565e6ed7471 (patch)
tree545cbf5f767298d4f206f88a2186ba9f90b637a0
parent18b641e590a7908dee4b3667a9196dbda484e477 (diff)
downloadcoinos-server-075361f1b32f52b220814aae0355c565e6ed7471.tar.gz
coinos-server-075361f1b32f52b220814aae0355c565e6ed7471.zip
combine balances
-rw-r--r--index.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/index.js b/index.js
index 85ffe932..46c4633e 100644
--- a/index.js
+++ b/index.js
@@ -256,7 +256,7 @@ const l = console.log
l('channel error', peer, err)
let msg = err.message
- if (msg.startsWith('Multiple') || msg.startsWith('You gave')) {
+ if (msg.startsWith('Multiple') || msg.startsWith('You gave') || msg.startsWith('peer')) {
busypeers.push(peer)
peer = lna.channelpeers.find(p => !busypeers.includes(p))
if (peer) {
@@ -314,7 +314,11 @@ const l = console.log
}
if (req.user.channelbalance < payreq.satoshis) {
- return res.status(500).send('Not enough satoshis')
+ if (req.user.balance + req.user.channelbalance < payreq.satoshis) {
+ return res.status(500).send('Not enough satoshis')
+ }
+ req.user.balance -= (payreq.satoshis - req.user.channelbalance)
+ req.user.channelbalance = 0
}
const stream = lna.sendPayment(lna.meta, {})
@@ -362,8 +366,11 @@ const l = console.log
}
if (req.user.balance < amount - MINFEE) {
- res.status(500).send('Not enough funds')
- return
+ if (req.user.balance + req.user.channelbalance < amount - MINFEE) {
+ return res.status(500).send('Not enough satoshis')
+ }
+ req.user.channelbalance -= (payreq.satoshis - req.user.balance)
+ req.user.balance = 0
}
try {