Merge pull request #1757 from MPOS/getrealbalance-wrapper

[ADDED] getrealbalance wrapper for payouts
This commit is contained in:
Sebastian Grewe 2014-02-16 08:11:08 +01:00
commit 5dd13d4475
2 changed files with 18 additions and 8 deletions

View File

@ -41,7 +41,7 @@ $sendmanyAvailable = ((strpos($bitcoin->help('sendmany'), 'unknown') === FALSE)
if ($sendmanyAvailable)
$log->logDebug(' sendmany available in coind help command');
if (!$dWalletBalance = $bitcoin->getbalance())
if (!$dWalletBalance = $bitcoin->getrealbalance())
$dWalletBalance = 0;
// Fetch outstanding manual-payouts
@ -113,7 +113,7 @@ if ($setting->getValue('disable_manual_payouts') != 1 && $aManualPayouts) {
}
}
if (!$dWalletBalance = $bitcoin->getbalance())
if (!$dWalletBalance = $bitcoin->getrealbalance())
$dWalletBalance = 0;
// Fetch outstanding auto-payouts

View File

@ -31,17 +31,27 @@ class BitcoinWrapper extends BitcoinClient {
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
return $this->memcache->setCache(__FUNCTION__, parent::getmininginfo(), 30);
}
// Wrapper to check our wallet balance from the DEFAULT account only
public function getbalance() {
$this->oDebug->append("STA " . __METHOD__, 4);
$aAccounts = parent::listaccounts();
return $aAccounts[''];
}
public function getblockcount() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
return $this->memcache->setCache(__FUNCTION__, parent::getblockcount(), 30);
}
// Wrapper method to get the real main account balance
public function getrealbalance() {
$this->oDebug->append("STA " . __METHOD__, 4);
$aAccounts = parent::listaccounts();
$dBalance = parent::getbalance();
// Account checks
if (count($aAccounts) == 1) {
// We only have a single account so getbalance will be fine
return $dBalance;
} else {
$dMainBalance = $aAccounts[''];
if ($dMainBalance < 0) return $dMainBalance;
$dUnconfirmed = $dMainBalance - abs($dBalance);
return $dMainBalance - abs($dUnconfirmed);
}
}
public function getdifficulty() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;