From dd3b4116a627504116e924aa1530d98c20d76623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Mon, 5 Apr 2021 17:48:18 +0100 Subject: [PATCH] refactor: remove duplicate function --- lib/plugins/zero-conf/blockcypher/blockcypher.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/plugins/zero-conf/blockcypher/blockcypher.js b/lib/plugins/zero-conf/blockcypher/blockcypher.js index 7e35e9d7..d6cb7775 100644 --- a/lib/plugins/zero-conf/blockcypher/blockcypher.js +++ b/lib/plugins/zero-conf/blockcypher/blockcypher.js @@ -30,6 +30,7 @@ function authorize (account, toAddress, cryptoAtoms, cryptoCode, isBitcoindAvail return axios.get(url) .then(r => { const data = r.data + const sumTxRefs = txrefs => _.sumBy(txref => highConfidence(confidence, txref), txrefs) if (isBitcoindAvailable && isRBFEnabled && data.unconfirmed_txrefs) { _.map(unconfirmedTxref => { promise.push(new Promise((resolve, reject) => { resolve(fetchRBF(unconfirmedTxref.tx_hash)) })) @@ -41,12 +42,10 @@ function authorize (account, toAddress, cryptoAtoms, cryptoCode, isBitcoindAvail if (rbfInfo.tx_hash === unconfirmedTxref.tx_hash) unconfirmedTxref.rbf = rbfInfo['bip125-replaceable'] }, data.unconfirmed_txrefs) }, values) - const sumTxRefs = txrefs => _.sumBy(txref => highConfidence(confidence, txref), txrefs) const authorizedValue = sumTxRefs(data.txrefs) + sumTxRefs(data.unconfirmed_txrefs) return cryptoAtoms.lte(authorizedValue) }) } else { - const sumTxRefs = txrefs => _.sumBy(txref => highConfidence(confidence, txref), txrefs) const authorizedValue = sumTxRefs(data.txrefs) + sumTxRefs(data.unconfirmed_txrefs) return cryptoAtoms.lte(authorizedValue) }