diff options
| author | Adam Soltys <[email protected]> | 2018-11-29 11:29:04 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2018-11-29 11:29:04 -0800 |
| commit | 075361f1b32f52b220814aae0355c565e6ed7471 (patch) | |
| tree | 545cbf5f767298d4f206f88a2186ba9f90b637a0 | |
| parent | 18b641e590a7908dee4b3667a9196dbda484e477 (diff) | |
| download | coinos-server-075361f1b32f52b220814aae0355c565e6ed7471.tar.gz coinos-server-075361f1b32f52b220814aae0355c565e6ed7471.zip | |
combine balances
| -rw-r--r-- | index.js | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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 { |
