Skip to content

Commit

Permalink
Add confirmations to BitcoinEsploraApiProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjablack committed Sep 12, 2019
1 parent 3772c19 commit b21c4f3
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -55,11 +55,13 @@ export default class BitcoinEsploraApiProvider extends Provider {

async _getUnspentTransactions (address) {
const response = await this._axios.get(`/address/${addressToString(address)}/utxo`)
const currentHeight = await this.getBlockHeight()
return response.data.map(utxo => ({
...utxo,
address: addressToString(address),
satoshis: utxo.value,
amount: BigNumber(utxo.value).dividedBy(1e8).toNumber()
amount: BigNumber(utxo.value).dividedBy(1e8).toNumber(),
confirmations: utxo.status.confirmed ? (currentHeight - utxo.status.block_height) + 1 : 0
}))
}

Expand Down

0 comments on commit b21c4f3

Please sign in to comment.