refactor: variable rename and remove trailing spaces

This commit is contained in:
José Oliveira 2021-04-04 21:53:55 +01:00 committed by Josh Harvey
parent d338d0adca
commit e62245098b

View file

@ -13,21 +13,24 @@ function highConfidence (confidence, txref) {
}
function authorize (account, toAddress, cryptoAtoms, cryptoCode, isBitcoindAvailable) {
var promise = []
let promise = []
return Promise.resolve()
.then(() => {
if (cryptoCode !== 'BTC') throw new Error('Unsupported crypto: ' + cryptoCode)
const query = qs.stringify({
token: account.token,
includeConfidence: true
})
const confidence = account.confidenceFactor
const verifyRBF = account.rbf
const isRBFEnabled = account.rbf
const url = `https://api.blockcypher.com/v1/btc/main/addrs/${toAddress}?${query}`
return axios.get(url)
.then(r => {
const data = r.data
if (isBitcoindAvailable && verifyRBF && data.unconfirmed_txrefs) {
if (isBitcoindAvailable && isRBFEnabled && data.unconfirmed_txrefs) {
_.map(unconfirmedTxref => {
promise.push(new Promise((resolve, reject) => { resolve(fetchRBF(unconfirmedTxref.tx_hash)) }))
}, data.unconfirmed_txrefs)
@ -49,4 +52,4 @@ function authorize (account, toAddress, cryptoAtoms, cryptoCode, isBitcoindAvail
}
})
})
}
}