From de8137aa64cb846faca8951ec1b61e0ffd4797dd Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 11 Feb 2014 10:31:23 +0100 Subject: [PATCH] [ADDED] Validate Payouts script added * Validate all DB transactions against your payouts in the RPC * Does not use TXID to search for records but rather a combination of address and amount * May help debugging issues --- scripts/validate_payouts.php | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/validate_payouts.php diff --git a/scripts/validate_payouts.php b/scripts/validate_payouts.php new file mode 100755 index 00000000..b05fdfef --- /dev/null +++ b/scripts/validate_payouts.php @@ -0,0 +1,82 @@ +#!/usr/bin/php +getTransactions(0, array('type' => 'Debit_MP'), $limit); +$aAllAPDebitTxs = $transaction->getTransactions(0, array('type' => 'Debit_AP'), $limit); +$aAllDebitTxs = array_merge($aAllMPDebitTxs, $aAllAPDebitTxs); + +// Fetch transactions from RPC +$aListTransactions = $bitcoin->listtransactions('', $rpclimit); + +// We don't need to loop through non-send transaction types +foreach ($aListTransactions as $key => $aTransaction) { + if ($aTransaction['category'] != 'send') { + unset($aListTransactions[$key]); + } +} + +// Initilize counters +$total=count($aListTransactions); +$found=0; +$notfound=0; + +// Output mask and header +$mask = "| %-15.15s | %-34.34s | %20.20s | %10.10s | %-64.64s |" . PHP_EOL; +printf($mask, 'Username', 'Address', 'Amount', 'Status', 'TXID'); + +// Loop through our DB records +foreach ($aAllDebitTxs as $aDebitTx) { + $bFound = false; + $txid = 'n/a'; + foreach($aListTransactions as $key => $aTransaction) { + // Search for match NOT by txid + if (isset($aTransaction['address']) && $aTransaction['address'] == $aDebitTx['coin_address'] && ($aTransaction['amount'] == ($aDebitTx['amount'] * -1) || $aTransaction['amount'] == ($aDebitTx['amount'] * -1 - $config['txfee_manual']) || $aTransaction['amount'] == ($aDebitTx['amount'] * -1 - $config['txfee_auto']) )) { + unset($aListTransactions[$key]); + $found++; + $bFound = true; + $status = 'FOUND'; + $txid = $aTransaction['txid']; + } + } + if (!$bFound) $status = 'MISSING'; + printf($mask, $aDebitTx['username'], $aDebitTx['coin_address'], $aDebitTx['amount'], $status, $txid); +} + +// Small summary +echo PHP_EOL . 'Summary: ' . PHP_EOL; +echo ' Total Send TX Records: ' . $total . PHP_EOL; +echo ' Total Debit Records: ' . count($aAllDebitTxs) . PHP_EOL; +echo ' Total Records Found: ' . $found . PHP_EOL;