From e37fb70a46899d2849c0e11bee62bdd712094585 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 4 Jun 2013 20:51:24 +0200 Subject: [PATCH] Do not deduct fees from balance when transmitting Fixes #106, we want to transfer the entire balance and let the RPC server deduct any fees that might apply. --- cronjobs/auto_payout.php | 6 +++--- public/include/pages/account/edit.inc.php | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cronjobs/auto_payout.php b/cronjobs/auto_payout.php index 3454ad9c..68b60aa4 100755 --- a/cronjobs/auto_payout.php +++ b/cronjobs/auto_payout.php @@ -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; diff --git a/public/include/pages/account/edit.inc.php b/public/include/pages/account/edit.inc.php index bb29cace..6308e271 100644 --- a/public/include/pages/account/edit.inc.php +++ b/public/include/pages/account/edit.inc.php @@ -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;