feat: add tx hash retrieval in wallet plugin

This commit is contained in:
José Oliveira 2022-07-19 20:14:40 +01:00
parent 3b01820242
commit 708dea736d
7 changed files with 56 additions and 6 deletions

View file

@ -125,11 +125,19 @@ function checkBlockchainStatus (cryptoCode) {
.then(res => !!res['initialblockdownload'] ? 'syncing' : 'ready')
}
function getTxHashesByAddress (cryptoCode, address) {
checkCryptoCode(cryptoCode)
.then(() => fetch('listreceivedbyaddress', [0, true, true, true, address]))
.then(txsByAddress => Promise.all(_.forEach(id => fetch('getrawtransaction', [id]), _.head(txsByAddress).txids)))
.then(_.map(({ hash }) => hash))
}
module.exports = {
balance,
sendCoins,
newAddress,
getStatus,
newFunding,
checkBlockchainStatus
checkBlockchainStatus,
getTxHashesByAddress
}