Merge pull request #107 from TheSerapher/issue-106

Do not deduct fees from balance when transmitting
This commit is contained in:
Sebastian Grewe 2013-06-04 11:52:41 -07:00
commit 8bc7f6bf44
2 changed files with 6 additions and 5 deletions

View File

@ -38,7 +38,7 @@ if (! empty($users)) {
$dBalance = $transaction->getBalance($aUserData['id']);
verbose($aUserData['id'] . "\t" . $aUserData['username'] . "\t" . $dBalance . "\t" . $aUserData['ap_threshold'] . "\t\t" . $aUserData['coin_address'] . "\t");
// Only run if balance meets threshold and can pay the transaction fee
// Only run if balance meets threshold and can pay the potential transaction fee
if ($dBalance > $aUserData['ap_threshold'] && $dBalance > 0.1) {
// Validate address against RPC
try {
@ -48,9 +48,9 @@ if (! empty($users)) {
continue;
}
// Send balance - 0.1 Fee to address
// Send balance, fees are reduced later
try {
$bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - 0.1);
$bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance);
} catch (BitcoinClientException $e) {
verbose("SEND FAILED\n");
continue;

View File

@ -16,6 +16,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST
$continue = true;
$dBalance = $transaction->getBalance($_SESSION['USERDATA']['id']);
$sCoinAddress = $user->getCoinAddress($_SESSION['USERDATA']['id']);
// Ensure we can cover the potential transaction fee of 0.1 LTC with the balance
if ($dBalance > 0.1) {
if ($bitcoin->can_connect() === true) {
try {
@ -25,9 +26,9 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST
$continue = false;
}
if ($continue == true) {
// Remove the transfer fee and send to address
// Send balance to address, mind 0.1 fee for transaction!
try {
$bitcoin->sendtoaddress($sCoinAddress, $dBalance - 0.1);
$bitcoin->sendtoaddress($sCoinAddress, $dBalance);
} catch (BitcoinClientException $e) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Failed to send LTC, please contact site support immidiately', 'TYPE' => 'errormsg');
$continue = false;