Browse Source

spv close connections fix

v0.25
pbca26 7 years ago
parent
commit
5d4a7d623b
  1. 7
      routes/shepherd/electrum/balance.js
  2. 2
      routes/shepherd/electrum/listunspent.js
  3. 6
      routes/shepherd/electrum/merkle.js
  4. 2
      routes/shepherd/electrum/transactions.js

7
routes/shepherd/electrum/balance.js

@ -13,7 +13,6 @@ module.exports = (shepherd) => {
json.hasOwnProperty('confirmed') && json.hasOwnProperty('confirmed') &&
json.hasOwnProperty('unconfirmed')) { json.hasOwnProperty('unconfirmed')) {
if (network === 'komodo') { if (network === 'komodo') {
ecl.connect();
ecl.blockchainAddressListunspent(req.query.address) ecl.blockchainAddressListunspent(req.query.address)
.then((utxoList) => { .then((utxoList) => {
if (utxoList && if (utxoList &&
@ -81,6 +80,8 @@ module.exports = (shepherd) => {
res.end(JSON.stringify(successObj)); res.end(JSON.stringify(successObj));
}); });
} else { } else {
ecl.close();
const successObj = { const successObj = {
msg: 'success', msg: 'success',
result: { result: {
@ -98,6 +99,8 @@ module.exports = (shepherd) => {
res.end(JSON.stringify(successObj)); res.end(JSON.stringify(successObj));
} }
} else { } else {
ecl.close();
const successObj = { const successObj = {
msg: 'success', msg: 'success',
result: { result: {
@ -133,6 +136,8 @@ module.exports = (shepherd) => {
res.end(JSON.stringify(successObj)); res.end(JSON.stringify(successObj));
} }
} else { } else {
ecl.close();
const successObj = { const successObj = {
msg: 'error', msg: 'error',
result: shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA, result: shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA,

2
routes/shepherd/electrum/listunspent.js

@ -26,6 +26,7 @@ module.exports = (shepherd) => {
} }
if (!_utxo.length) { // no confirmed utxo if (!_utxo.length) { // no confirmed utxo
ecl.close();
resolve('no valid utxo'); resolve('no valid utxo');
} else { } else {
shepherd.Promise.all(_utxo.map((_utxoItem, index) => { shepherd.Promise.all(_utxo.map((_utxoItem, index) => {
@ -129,6 +130,7 @@ module.exports = (shepherd) => {
}); });
} }
} else { } else {
ecl.close();
resolve('cant get current height'); resolve('cant get current height');
} }
}); });

6
routes/shepherd/electrum/merkle.js

@ -83,13 +83,16 @@ module.exports = (shepherd) => {
resolve(false); resolve(false);
} }
} else { } else {
ecl.close();
resolve(shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA); resolve(shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA);
} }
} else { } else {
ecl.close();
resolve(shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA); resolve(shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA);
} }
}); });
} else { } else {
ecl.close();
resolve(shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA); resolve(shepherd.CONNECTION_ERROR_OR_INCOMPLETE_DATA);
} }
}); });
@ -118,7 +121,8 @@ module.exports = (shepherd) => {
height, height,
_filteredServerList, _filteredServerList,
shepherd.electrumCoins[coin].server.ip + ':' + shepherd.electrumCoins[coin].server.port + ':' + shepherd.electrumServers[coin === 'KMD' || coin === 'komodo' ? 'komodo' : coin.toLowerCase()].proto shepherd.electrumCoins[coin].server.ip + ':' + shepherd.electrumCoins[coin].server.port + ':' + shepherd.electrumServers[coin === 'KMD' || coin === 'komodo' ? 'komodo' : coin.toLowerCase()].proto
).then((proof) => { )
.then((proof) => {
resolve(proof); resolve(proof);
}); });
} else { } else {

2
routes/shepherd/electrum/transactions.js

@ -188,6 +188,8 @@ module.exports = (shepherd) => {
res.end(JSON.stringify(successObj)); res.end(JSON.stringify(successObj));
}); });
} else { } else {
ecl.close();
const successObj = { const successObj = {
msg: 'success', msg: 'success',
result: [], result: [],

Loading…
Cancel
Save