Adding transaction fees to transaction class

This will add back the transaction fees. Prior to this commit the pool
had to cover the transaction fees. Now for each transaction the full
balance is transferred (RPC Daemon will remove the TX Fee) but two
transactions are added. One for the Debig and one TXFee.

Fixes #203.

**Requires database upgrade with supplied SQL file**
This commit is contained in:
Sebastian Grewe 2013-06-17 11:17:15 +02:00
parent c93b6068a3
commit fa7f61c436
5 changed files with 8 additions and 6 deletions

View File

@ -61,7 +61,7 @@ if (! empty($users)) {
}
// Create transaction record
if ($transaction->addTransaction($aUserData['id'], $dBalance, 'Debit_AP', NULL, $aUserData['coin_address'])) {
if ($transaction->addTransaction($aUserData['id'], $dBalance - $config['txfee'], 'Debit_AP', NULL, $aUserData['coin_address']) && $transaction->addTransaction($aUserData['id'], $config['txfee'], 'TXFee', NULL, $aUserData['coin_address'])) {
// Notify user via mail
$aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id']));
$aMailData['subject'] = 'Auto Payout Completed';

View File

@ -147,7 +147,7 @@ class Transaction {
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
WHERE (
( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR
t.type IN ('Donation_PPS','Fee_PPS')
t.type IN ('Donation_PPS','Fee_PPS','TXFee')
)
) AS t3");
if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $this->config['confirmations'], $this->config['confirmations']) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch())
@ -194,7 +194,7 @@ class Transaction {
WHERE
(
( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR
( t.type IN ('Donation_PPS', 'Fee_PPS') )
( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') )
)
AND t.account_id = ?
) AS t3,
@ -216,7 +216,7 @@ class Transaction {
WHERE
(
( t.type IN ('Donation','Fee') AND b.confirmations < ? ) OR
( t.type IN ('Donation_PPS', 'Fee_PPS') )
( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') )
)
AND t.account_id = ?
) AS t5

View File

@ -29,7 +29,7 @@ if ($user->isAuthenticated()) {
}
if ($continue == true) {
// Send balance to address, mind fee for transaction!
try {
try {
if ($setting->getValue('auto_payout_active') == 0) {
$bitcoin->sendtoaddress($sCoinAddress, $dBalance);
} else {
@ -42,7 +42,7 @@ if ($user->isAuthenticated()) {
}
}
// Set balance to 0, add to paid out, insert to ledger
if ($continue == true && $transaction->addTransaction($_SESSION['USERDATA']['id'], $dBalance, 'Debit_MP', NULL, $sCoinAddress)) {
if ($continue == true && $transaction->addTransaction($_SESSION['USERDATA']['id'], $dBalance - $config['txfee'], 'Debit_MP', NULL, $sCoinAddress) && $transaction->addTransaction($_SESSION['USERDATA']['id'], $config['txfee'], 'TXFee', NULL, $sCoinAddress) ) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Transaction completed', 'TYPE' => 'success');
$aMailData['email'] = $user->getUserEmail($user->getUserName($_SESSION['USERDATA']['id']));
$aMailData['amount'] = $dBalance;

View File

@ -24,6 +24,7 @@
or $TRANSACTIONS[transaction].type == 'Donation_PPS'
or $TRANSACTIONS[transaction].type == 'Debit_AP'
or $TRANSACTIONS[transaction].type == 'Debit_MP'
or $TRANSACTIONS[transaction].type == 'TXFee'
)}
<tr class="{cycle values="odd,even"}">
<td>{$TRANSACTIONS[transaction].id}</td>

View File

@ -0,0 +1 @@
ALTER TABLE `transactions` CHANGE `type` `type` ENUM( 'Credit', 'Debit_MP', 'Debit_AP', 'Donation', 'Fee', 'Orphan_Credit', 'Orphan_Fee', 'Orphan_Donation', 'Credit_PPS', 'Fee_PPS', 'Donation_PPS', 'TXFee' ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;