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:
parent
c93b6068a3
commit
fa7f61c436
@ -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';
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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>
|
||||
|
||||
1
sql/issue_203_transactions_upgrade.sql
Normal file
1
sql/issue_203_transactions_upgrade.sql
Normal 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 ;
|
||||
Loading…
Reference in New Issue
Block a user