Merge pull request #107 from TheSerapher/issue-106
Do not deduct fees from balance when transmitting
This commit is contained in:
commit
8bc7f6bf44
@ -38,7 +38,7 @@ if (! empty($users)) {
|
|||||||
$dBalance = $transaction->getBalance($aUserData['id']);
|
$dBalance = $transaction->getBalance($aUserData['id']);
|
||||||
verbose($aUserData['id'] . "\t" . $aUserData['username'] . "\t" . $dBalance . "\t" . $aUserData['ap_threshold'] . "\t\t" . $aUserData['coin_address'] . "\t");
|
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) {
|
if ($dBalance > $aUserData['ap_threshold'] && $dBalance > 0.1) {
|
||||||
// Validate address against RPC
|
// Validate address against RPC
|
||||||
try {
|
try {
|
||||||
@ -48,9 +48,9 @@ if (! empty($users)) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send balance - 0.1 Fee to address
|
// Send balance, fees are reduced later
|
||||||
try {
|
try {
|
||||||
$bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - 0.1);
|
$bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance);
|
||||||
} catch (BitcoinClientException $e) {
|
} catch (BitcoinClientException $e) {
|
||||||
verbose("SEND FAILED\n");
|
verbose("SEND FAILED\n");
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -16,6 +16,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST
|
|||||||
$continue = true;
|
$continue = true;
|
||||||
$dBalance = $transaction->getBalance($_SESSION['USERDATA']['id']);
|
$dBalance = $transaction->getBalance($_SESSION['USERDATA']['id']);
|
||||||
$sCoinAddress = $user->getCoinAddress($_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 ($dBalance > 0.1) {
|
||||||
if ($bitcoin->can_connect() === true) {
|
if ($bitcoin->can_connect() === true) {
|
||||||
try {
|
try {
|
||||||
@ -25,9 +26,9 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST
|
|||||||
$continue = false;
|
$continue = false;
|
||||||
}
|
}
|
||||||
if ($continue == true) {
|
if ($continue == true) {
|
||||||
// Remove the transfer fee and send to address
|
// Send balance to address, mind 0.1 fee for transaction!
|
||||||
try {
|
try {
|
||||||
$bitcoin->sendtoaddress($sCoinAddress, $dBalance - 0.1);
|
$bitcoin->sendtoaddress($sCoinAddress, $dBalance);
|
||||||
} catch (BitcoinClientException $e) {
|
} catch (BitcoinClientException $e) {
|
||||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Failed to send LTC, please contact site support immidiately', 'TYPE' => 'errormsg');
|
$_SESSION['POPUP'][] = array('CONTENT' => 'Failed to send LTC, please contact site support immidiately', 'TYPE' => 'errormsg');
|
||||||
$continue = false;
|
$continue = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user