diff --git a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js index 0ef29ede..fd141ede 100644 --- a/lib/plugins/wallet/bitcoincashd/bitcoincashd.js +++ b/lib/plugins/wallet/bitcoincashd/bitcoincashd.js @@ -25,16 +25,22 @@ function checkCryptoCode (cryptoCode) { return Promise.resolve() } -function accountBalance (account, cryptoCode, confirmations) { +function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getbalance', ['*', confirmations])) - .then(r => BN(r).shift(unitScale).round()) + .then(() => fetch('getwalletinfo')) + .then(({ balance }) => BN(balance).shift(unitScale).round()) +} + +function accountUnconfirmedBalance (cryptoCode) { + return checkCryptoCode(cryptoCode) + .then(() => fetch('getwalletinfo')) + .then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round()) } // We want a balance that includes all spends (0 conf) but only deposits that // have at least 1 confirmation. getbalance does this for us automatically. function balance (account, cryptoCode) { - return accountBalance(account, cryptoCode, 1) + return accountBalance(cryptoCode) } function sendCoins (account, address, cryptoAtoms, cryptoCode) { @@ -95,9 +101,9 @@ function newFunding (account, cryptoCode) { return checkCryptoCode(cryptoCode) .then(() => { const promises = [ - accountBalance(account, cryptoCode, 0), - accountBalance(account, cryptoCode, 1), - newAddress(account, {cryptoCode}) + accountUnconfirmedBalance(cryptoCode), + accountBalance(cryptoCode), + newAddress(account, { cryptoCode }) ] return Promise.all(promises) diff --git a/lib/plugins/wallet/bitcoind/bitcoind.js b/lib/plugins/wallet/bitcoind/bitcoind.js index a8fc91f2..e424eeef 100644 --- a/lib/plugins/wallet/bitcoind/bitcoind.js +++ b/lib/plugins/wallet/bitcoind/bitcoind.js @@ -25,16 +25,22 @@ function checkCryptoCode (cryptoCode) { return Promise.resolve() } -function accountBalance (account, cryptoCode, confirmations) { +function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getbalance', ['*', confirmations])) - .then(r => BN(r).shift(unitScale).round()) + .then(() => fetch('getwalletinfo')) + .then(({ balance }) => BN(balance).shift(unitScale).round()) +} + +function accountUnconfirmedBalance (cryptoCode) { + return checkCryptoCode(cryptoCode) + .then(() => fetch('getwalletinfo')) + .then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round()) } // We want a balance that includes all spends (0 conf) but only deposits that // have at least 1 confirmation. getbalance does this for us automatically. function balance (account, cryptoCode) { - return accountBalance(account, cryptoCode, 1) + return accountBalance(cryptoCode) } function sendCoins (account, address, cryptoAtoms, cryptoCode) { @@ -95,9 +101,9 @@ function newFunding (account, cryptoCode) { return checkCryptoCode(cryptoCode) .then(() => { const promises = [ - accountBalance(account, cryptoCode, 0), - accountBalance(account, cryptoCode, 1), - newAddress(account, {cryptoCode}) + accountUnconfirmedBalance(cryptoCode), + accountBalance(cryptoCode), + newAddress(account, { cryptoCode }) ] return Promise.all(promises) diff --git a/lib/plugins/wallet/dashd/dashd.js b/lib/plugins/wallet/dashd/dashd.js index 4d664269..33c86c13 100644 --- a/lib/plugins/wallet/dashd/dashd.js +++ b/lib/plugins/wallet/dashd/dashd.js @@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) { return Promise.resolve() } -function accountBalance (acount, cryptoCode, confirmations) { +function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getbalance', ['', confirmations])) - .then(r => BN(r).shift(unitScale).round()) + .then(() => fetch('getwalletinfo')) + .then(({ balance }) => BN(balance).shift(unitScale).round()) +} + +function accountUnconfirmedBalance (cryptoCode) { + return checkCryptoCode(cryptoCode) + .then(() => fetch('getwalletinfo')) + .then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round()) } // We want a balance that includes all spends (0 conf) but only deposits that // have at least 1 confirmation. getbalance does this for us automatically. function balance (account, cryptoCode) { - return accountBalance(account, cryptoCode, 1) + return accountBalance(cryptoCode) } function sendCoins (account, address, cryptoAtoms, cryptoCode) { @@ -96,9 +102,9 @@ function newFunding (account, cryptoCode) { return checkCryptoCode(cryptoCode) .then(() => { const promises = [ - accountBalance(account, cryptoCode, 0), - accountBalance(account, cryptoCode, 1), - newAddress(account, {cryptoCode}) + accountUnconfirmedBalance(cryptoCode), + accountBalance(cryptoCode), + newAddress(account, { cryptoCode }) ] return Promise.all(promises) diff --git a/lib/plugins/wallet/litecoind/litecoind.js b/lib/plugins/wallet/litecoind/litecoind.js index fc4c9bce..234b816e 100644 --- a/lib/plugins/wallet/litecoind/litecoind.js +++ b/lib/plugins/wallet/litecoind/litecoind.js @@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) { return Promise.resolve() } -function accountBalance (acount, cryptoCode, confirmations) { +function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getbalance', ['*', confirmations])) - .then(r => BN(r).shift(unitScale).round()) + .then(() => fetch('getwalletinfo')) + .then(({ balance }) => BN(balance).shift(unitScale).round()) +} + +function accountUnconfirmedBalance (cryptoCode) { + return checkCryptoCode(cryptoCode) + .then(() => fetch('getwalletinfo')) + .then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round()) } // We want a balance that includes all spends (0 conf) but only deposits that // have at least 1 confirmation. getbalance does this for us automatically. function balance (account, cryptoCode) { - return accountBalance(account, cryptoCode, 1) + return accountBalance(cryptoCode) } function sendCoins (account, address, cryptoAtoms, cryptoCode) { @@ -96,9 +102,9 @@ function newFunding (account, cryptoCode) { return checkCryptoCode(cryptoCode) .then(() => { const promises = [ - accountBalance(account, cryptoCode, 0), - accountBalance(account, cryptoCode, 1), - newAddress(account, {cryptoCode}) + accountUnconfirmedBalance(cryptoCode), + accountBalance(cryptoCode), + newAddress(account, { cryptoCode }) ] return Promise.all(promises) diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index 1f9e7656..b5b23da6 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) { return Promise.resolve() } -function accountBalance (acount, cryptoCode, confirmations) { +function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getbalance', ['', confirmations])) - .then(r => BN(r).shift(unitScale).round()) + .then(() => fetch('getwalletinfo')) + .then(({ balance }) => BN(balance).shift(unitScale).round()) +} + +function accountUnconfirmedBalance (cryptoCode) { + return checkCryptoCode(cryptoCode) + .then(() => fetch('getwalletinfo')) + .then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round()) } // We want a balance that includes all spends (0 conf) but only deposits that // have at least 1 confirmation. getbalance does this for us automatically. function balance (account, cryptoCode) { - return accountBalance(account, cryptoCode, 1) + return accountBalance(cryptoCode) } function sendCoins (account, address, cryptoAtoms, cryptoCode) { @@ -96,9 +102,9 @@ function newFunding (account, cryptoCode) { return checkCryptoCode(cryptoCode) .then(() => { const promises = [ - accountBalance(account, cryptoCode, 0), - accountBalance(account, cryptoCode, 1), - newAddress(account, {cryptoCode}) + accountUnconfirmedBalance(cryptoCode), + accountBalance(cryptoCode), + newAddress(account, { cryptoCode }) ] return Promise.all(promises)