From 13fc01243e56bd9499616db7f6c89bec9f1b9b7c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 12 Jun 2013 13:36:44 +0200 Subject: [PATCH 1/3] Adding configurable currency name to global config Addresses #138 --- public/include/config/global.inc.dist.php | 1 + public/include/pages/account/edit.inc.php | 6 +++--- public/include/smarty_globals.inc.php | 2 ++ public/templates/mmcFE/account/edit/default.tpl | 6 +++--- public/templates/mmcFE/global/header.tpl | 2 +- public/templates/mmcFE/global/sidebar.tpl | 8 ++++---- .../mmcFE/statistics/pool/contributors_hashrate.tpl | 4 ++-- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index df743132..934df25d 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -34,6 +34,7 @@ $config = array( 'slogan' => 'Resistance is futile', 'email' => 'test@example.com', // Mail address used for notifications ), + 'currency' => 'LTC', // Currency name to be used on website 'block_bonus' => 0, 'payout_system' => 'prop', // Set your payout here so template changes are activated 'archive_shares' => true, // Store accounted shares in archive table? diff --git a/public/include/pages/account/edit.inc.php b/public/include/pages/account/edit.inc.php index 345816a7..968ecfbe 100644 --- a/public/include/pages/account/edit.inc.php +++ b/public/include/pages/account/edit.inc.php @@ -21,7 +21,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST $aBalance = $transaction->getBalance($_SESSION['USERDATA']['id']); $dBalance = $aBalance['confirmed']; $sCoinAddress = $user->getCoinAddress($_SESSION['USERDATA']['id']); - // Ensure we can cover the potential transaction fee of 0.1 LTC with the balance + // Ensure we can cover the potential transaction fee of 0.1 with the balance if ($dBalance > 0.1) { if ($bitcoin->can_connect() === true) { try { @@ -40,7 +40,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST $continue = false; } } 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 ' . $config['currency'] . ', please contact site support immidiately', 'TYPE' => 'errormsg'); $continue = false; } } @@ -56,7 +56,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service', 'TYPE' => 'errormsg'); } } else { - $_SESSION['POPUP'][] = array('CONTENT' => 'Insufficient funds, you need more than 0.1 LTC to cover transaction fees', 'TYPE' => 'errormsg'); + $_SESSION['POPUP'][] = array('CONTENT' => 'Insufficient funds, you need more than 0.1 ' . $conifg['currency'] . ' to cover transaction fees', 'TYPE' => 'errormsg'); } $setting->setValue('manual_payout_active', 0); } diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 209f6a71..950f1db6 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -18,6 +18,7 @@ if ($bitcoin->can_connect() === true){ $dDifficulty = 1; } +// Global data for Smarty $aGlobal = array( 'slogan' => $config['website']['slogan'], 'websitename' => $config['website']['name'], @@ -33,6 +34,7 @@ $aGlobal = array( 'blockexplorer' => $config['blockexplorer'], 'chaininfo' => $config['chaininfo'], 'config' => array( + 'currency' => $config['currency'], 'payout_system' => $config['payout_system'], 'ap_threshold' => array( 'min' => $config['ap_threshold']['min'], diff --git a/public/templates/mmcFE/account/edit/default.tpl b/public/templates/mmcFE/account/edit/default.tpl index 86f4f02d..e5c31eab 100644 --- a/public/templates/mmcFE/account/edit/default.tpl +++ b/public/templates/mmcFE/account/edit/default.tpl @@ -10,20 +10,20 @@ E-Mail: Payment Address: Donation %: [donation amount in percent (example: 0.5)] - Automatic Payout Threshold: [{$GLOBAL.config.ap_threshold.min}-{$GLOBAL.config.ap_threshold.max} LTC. Set to '0' for no auto payout] + Automatic Payout Threshold: [{$GLOBAL.config.ap_threshold.min}-{$GLOBAL.config.ap_threshold.max} {$GLOBAL.config.currency}. Set to '0' for no auto payout] 4 digit PIN: [The 4 digit PIN you chose when registering] {include file="global/block_footer.tpl"} {include file="global/block_header.tpl" BLOCK_HEADER="Cash Out"} - +
- +
Account Balance:    {$GLOBAL.userdata.balance.confirmed|escape} LTC
Account Balance:    {$GLOBAL.userdata.balance.confirmed|escape} {$GLOABL.config.currency}
Payout to:
{$GLOBAL.userdata.coin_address|escape}
4 digit PIN:
diff --git a/public/templates/mmcFE/global/header.tpl b/public/templates/mmcFE/global/header.tpl index 126fde52..a4b23f4b 100644 --- a/public/templates/mmcFE/global/header.tpl +++ b/public/templates/mmcFE/global/header.tpl @@ -4,7 +4,7 @@
- + diff --git a/public/templates/mmcFE/global/sidebar.tpl b/public/templates/mmcFE/global/sidebar.tpl index 6049f9ac..34018785 100644 --- a/public/templates/mmcFE/global/sidebar.tpl +++ b/public/templates/mmcFE/global/sidebar.tpl @@ -49,7 +49,7 @@ {if $GLOBAL.config.payout_system != 'pps'} - + @@ -69,9 +69,9 @@ {/if} - - - + + +
  • LTC/usd: {$GLOBAL.price|default:"n/a"|number_format:"4"}    
  • {$GLOBAL.config.currency}/usd: {$GLOBAL.price|default:"n/a"|number_format:"4"}    
  • Pool Hashrate: {($GLOBAL.hashrate / 1000)|number_format:"3"} MH/s    
  • Pool Sharerate: {$GLOBAL.sharerate|number_format:"2"} Shares/s    
  • Pool Workers: {$GLOBAL.workers}    
  • LTC Round Estimate{$GLOBAL.config.currency} Round Estimate
    Block
     
    Account Balance
    Confirmed{$GLOBAL.userdata.balance.confirmed|default:"0"} LTC
    Unconfirmed{$GLOBAL.userdata.balance.unconfirmed|default:"0"} LTC
    {$GLOBAL.config.currency} Account Balance
    Confirmed{$GLOBAL.userdata.balance.confirmed|default:"0"}
    Unconfirmed{$GLOBAL.userdata.balance.unconfirmed|default:"0"}
    diff --git a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl index 37e6e6a8..67c8f5d7 100644 --- a/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl +++ b/public/templates/mmcFE/statistics/pool/contributors_hashrate.tpl @@ -6,8 +6,8 @@ Rank User Name KH/s - Ł/Day (est) - Usd/Day (est) + {$GLOBAL.config.currency}/Day + Usd/Day From a2ad57e92aaa3c122017d8f657ed8b625b33d33e Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 12 Jun 2013 13:46:29 +0200 Subject: [PATCH 2/3] Adding configurable TX Fee for web interface * This does not actually check the TX fee set on the RPC side * Ensures TX fee is covered before doing transactions * Display TX fee when required Fixes #138 --- cronjobs/auto_payout.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cronjobs/auto_payout.php b/cronjobs/auto_payout.php index ca33dc3f..366298e1 100755 --- a/cronjobs/auto_payout.php +++ b/cronjobs/auto_payout.php @@ -43,7 +43,7 @@ if (! empty($users)) { 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 potential transaction fee - if ($dBalance > $aUserData['ap_threshold'] && $dBalance > 0.1) { + if ($dBalance > $aUserData['ap_threshold'] && $dBalance > $config['txfee']) { // Validate address against RPC try { $bitcoin->validateaddress($aUserData['coin_address']); @@ -52,7 +52,7 @@ if (! empty($users)) { continue; } - // Send balance, fees are reduced later + // Send balance, fees are reduced later by RPC Server try { $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance); } catch (BitcoinClientException $e) { @@ -61,7 +61,7 @@ if (! empty($users)) { } // Create transaction record - if ($transaction->addTransaction($aUserData['id'], $dBalance, 'Debit_AP', NULL, $aUserData['coin_address'], 0.1)) { + if ($transaction->addTransaction($aUserData['id'], $dBalance, 'Debit_AP', NULL, $aUserData['coin_address'])) { // Notify user via mail $aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id'])); $aMailData['subject'] = 'Auto Payout Completed'; @@ -76,7 +76,7 @@ if (! empty($users)) { } } else { - verbose("SKIPPED\n"); + verbose("INSUFF_TXFEE\n"); } } } else { From 8859f0c0915950ceadcc81ecff2d3b275d9009d4 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 12 Jun 2013 13:51:10 +0200 Subject: [PATCH 3/3] forgot to add the actual files :/ --- public/include/config/global.inc.dist.php | 1 + public/include/pages/account/edit.inc.php | 8 ++++---- public/include/smarty_globals.inc.php | 1 + public/templates/mmcFE/account/edit/default.tpl | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 934df25d..e8d12774 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -35,6 +35,7 @@ $config = array( 'email' => 'test@example.com', // Mail address used for notifications ), 'currency' => 'LTC', // Currency name to be used on website + 'txfee' => 0.1, // Default tx fee added by RPC server 'block_bonus' => 0, 'payout_system' => 'prop', // Set your payout here so template changes are activated 'archive_shares' => true, // Store accounted shares in archive table? diff --git a/public/include/pages/account/edit.inc.php b/public/include/pages/account/edit.inc.php index 968ecfbe..6726b7d9 100644 --- a/public/include/pages/account/edit.inc.php +++ b/public/include/pages/account/edit.inc.php @@ -21,8 +21,8 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST $aBalance = $transaction->getBalance($_SESSION['USERDATA']['id']); $dBalance = $aBalance['confirmed']; $sCoinAddress = $user->getCoinAddress($_SESSION['USERDATA']['id']); - // Ensure we can cover the potential transaction fee of 0.1 with the balance - if ($dBalance > 0.1) { + // Ensure we can cover the potential transaction fee + if ($dBalance > $config['txfee']) { if ($bitcoin->can_connect() === true) { try { $bitcoin->validateaddress($sCoinAddress); @@ -31,7 +31,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST $continue = false; } if ($continue == true) { - // Send balance to address, mind 0.1 fee for transaction! + // Send balance to address, mind fee for transaction! try { if ($setting->getValue('auto_payout_active') == 0) { $bitcoin->sendtoaddress($sCoinAddress, $dBalance); @@ -56,7 +56,7 @@ if ( ! $user->checkPin($_SESSION['USERDATA']['id'], $_POST['authPin']) && $_POST $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service', 'TYPE' => 'errormsg'); } } else { - $_SESSION['POPUP'][] = array('CONTENT' => 'Insufficient funds, you need more than 0.1 ' . $conifg['currency'] . ' to cover transaction fees', 'TYPE' => 'errormsg'); + $_SESSION['POPUP'][] = array('CONTENT' => 'Insufficient funds, you need more than ' . $config['txfee'] . ' ' . $conifg['currency'] . ' to cover transaction fees', 'TYPE' => 'errormsg'); } $setting->setValue('manual_payout_active', 0); } diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 950f1db6..8ec1e882 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -35,6 +35,7 @@ $aGlobal = array( 'chaininfo' => $config['chaininfo'], 'config' => array( 'currency' => $config['currency'], + 'txfee' => $config['txfee'], 'payout_system' => $config['payout_system'], 'ap_threshold' => array( 'min' => $config['ap_threshold']['min'], diff --git a/public/templates/mmcFE/account/edit/default.tpl b/public/templates/mmcFE/account/edit/default.tpl index e5c31eab..f48ef67f 100644 --- a/public/templates/mmcFE/account/edit/default.tpl +++ b/public/templates/mmcFE/account/edit/default.tpl @@ -17,7 +17,7 @@ {include file="global/block_footer.tpl"} {include file="global/block_header.tpl" BLOCK_HEADER="Cash Out"} -
    • Please note: a 0.1 {$GLOBAL.config.currency} transaction will apply when processing "On-Demand" manual payments
    +
    • Please note: a {$GLOBAL.config.txfee} {$GLOBAL.config.currency} transaction will apply when processing "On-Demand" manual payments