From bc1925a14c19e6b0395bfca8472719937a288ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Thu, 21 Jul 2022 10:22:24 +0100 Subject: [PATCH] fix: promise all array values and monero get_transfers arg --- lib/plugins/wallet/bitcoincashd/bitcoincashd.js | 2 +- lib/plugins/wallet/bitcoind/bitcoind.js | 2 +- lib/plugins/wallet/dashd/dashd.js | 2 +- lib/plugins/wallet/monerod/monerod.js | 4 ++-- lib/plugins/wallet/zcashd/zcashd.js | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js index 9fb3cd09..1208a19e 100644 --- a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js +++ b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js @@ -132,7 +132,7 @@ function checkBlockchainStatus (cryptoCode) { function getTxHashesByAddress (cryptoCode, address) { checkCryptoCode(cryptoCode) .then(() => fetch('listreceivedbyaddress', [0, true, true, address])) - .then(txsByAddress => Promise.all(_.forEach(id => fetch('getrawtransaction', [id]), _.head(txsByAddress).txids))) + .then(txsByAddress => Promise.all(_.map(id => fetch('getrawtransaction', [id]), _.flatMap(it => it.txids, txsByAddress)))) .then(_.map(({ hash }) => hash)) } diff --git a/lib/plugins/wallet/bitcoind/bitcoind.js b/lib/plugins/wallet/bitcoind/bitcoind.js index 2a52e01b..cc30e4b4 100644 --- a/lib/plugins/wallet/bitcoind/bitcoind.js +++ b/lib/plugins/wallet/bitcoind/bitcoind.js @@ -194,7 +194,7 @@ function checkBlockchainStatus (cryptoCode) { function getTxHashesByAddress (cryptoCode, address) { checkCryptoCode(cryptoCode) .then(() => fetch('listreceivedbyaddress', [0, true, true, address])) - .then(txsByAddress => Promise.all(_.forEach(id => fetch('getrawtransaction', [id]), _.head(txsByAddress).txids))) + .then(txsByAddress => Promise.all(_.map(id => fetch('getrawtransaction', [id]), _.flatMap(it => it.txids, txsByAddress)))) .then(_.map(({ hash }) => hash)) } diff --git a/lib/plugins/wallet/dashd/dashd.js b/lib/plugins/wallet/dashd/dashd.js index 9b84a6a0..e5167332 100644 --- a/lib/plugins/wallet/dashd/dashd.js +++ b/lib/plugins/wallet/dashd/dashd.js @@ -128,7 +128,7 @@ function checkBlockchainStatus (cryptoCode) { 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(txsByAddress => Promise.all(_.map(id => fetch('getrawtransaction', [id]), _.flatMap(it => it.txids, txsByAddress)))) .then(_.map(({ hash }) => hash)) } diff --git a/lib/plugins/wallet/monerod/monerod.js b/lib/plugins/wallet/monerod/monerod.js index 1ed93bf8..0d938dc0 100644 --- a/lib/plugins/wallet/monerod/monerod.js +++ b/lib/plugins/wallet/monerod/monerod.js @@ -164,7 +164,7 @@ function getStatus (account, tx, requested, settings, operatorId) { return checkCryptoCode(cryptoCode) .then(() => refreshWallet()) .then(() => fetch('get_address_index', { address: toAddress })) - .then(addressRes => fetch('get_transfers', { in: true, pool: true, account_index: addressRes.index.major, address_indices: [addressRes.index.minor] })) + .then(addressRes => fetch('get_transfers', { in: true, pool: true, account_index: addressRes.index.major, subaddr_indices: [addressRes.index.minor] })) .then(transferRes => { const confirmedToAddress = _.filter(it => it.address === toAddress, transferRes.in ?? []) const pendingToAddress = _.filter(it => it.address === toAddress, transferRes.pool ?? []) @@ -239,7 +239,7 @@ function getTxHashesByAddress (cryptoCode, address) { checkCryptoCode(cryptoCode) .then(() => refreshWallet()) .then(() => fetch('get_address_index', { address: address })) - .then(addressRes => fetch('get_transfers', { in: true, pool: true, pending: true, account_index: addressRes.index.major, address_indices: [addressRes.index.minor] })) + .then(addressRes => fetch('get_transfers', { in: true, pool: true, pending: true, account_index: addressRes.index.major, subaddr_indices: [addressRes.index.minor] })) .then(_.map(({ txid }) => txid)) } diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index f0fb27f4..dfacdbc2 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -154,7 +154,6 @@ function checkBlockchainStatus (cryptoCode) { function getTxHashesByAddress (cryptoCode, address) { checkCryptoCode(cryptoCode) .then(() => fetch('getaddresstxids', [address])) - .then(_.values) } module.exports = {