par
Daniel » 20 avr. 2016, 22:31
Bonjour a tous.
quelqu'un pourrait me aider?
je suis très débutant et je ne arrive pas toujours le même erreur
include('config.php');
require_once 'easybitcoin.php';
$client = new Bitcoin($rpc['login'] , $rpc['password'] , $rpc['ip'] , $rpc['port']) or die('Error: could not connect to RPC server.');
$lastPayout = time();
$adresses = array();
function getAddress($trans)
{
global $client;
$address = "";
$details = $client->getrawtransaction($trans["txid"], 1);
$vintxid = $details['vin'][0]['txid'];
$vinvout = $details['vin'][0]['vout'];
try {
$transactionin = $client->getrawtransaction($vintxid, 1);
}
catch (Exception $e) {
die("Error with getting transaction details.\nYou should add 'txindex=1' to your .conf file and then run the daemon with the -reindex parameter.");
}
if ($vinvout == 1)
$vinvout = 0;
else
$vinvout = 1;
$address = $transactionin['vout'][!$vinvout]['scriptPubKey']['addresses'][0];
return $address;
echo $address;
}
// Paying out
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `state` = 1 ORDER BY `date` ASC;');
if (mysqli_fetch_assoc($query)) {
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `state` = 1 ORDER BY `date` ASC;');
while($row = mysqli_fetch_assoc($query))
{
if ($row['date'] + $config['payout-check'] < time()) {
$txout = $client->sendfrom($config['ponziacc'], $row['address'], round((float)$row['topay'], 4) - ($row['amount'] * $config['fee']));
mysqli_query($mysqli,"UPDATE `transactions` SET `state` = 2, `out` = '" . $txout . "' WHERE `id` = " . $row['id'] . ";");
print("Paying:<br>");
print($row['topay'] . " " . $config['val'] ." sent to " . $row['address'] . ".\n");
echo ("<br>");
}
}
}
// Parsing and adding new transactions to database
print("Parsing transactions...\n");
echo ("<br>");
$transactions = $client->listtransactions($config['ponziacc'], 100);
$i = 0;
// if (getAddress($transactions))
// {
foreach ($transactions as $trans)
{
echo("" . ++$i . ",\n");
if ($trans['category'] != "receive" || $trans["confirmations"] < $config['confirmations'])
continue;
if ($trans['amount'] > $config['max'] || $trans['amount'] < $config['min'])
{
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `tx` = "'.$trans['txid'].'";');
echo $query;
if (!mysqli_fetch_assoc($query))
{
if ($trans['amount'] < 0)
continue;
if ($config['sendback'])
$client->sendtoaddress(getAddress($trans), $trans['amount'] - ($trans['amount'] * $config['fee']));
else
$client->sendtoaddress($config['ownaddress'], $trans['amount'] - ($trans['amount'] * $config['fee']));
mysqli_query($mysqli,"INSERT INTO `transactions` (`id`, `amount`, `topay`, `address`, `state`, `tx`, `date`) VALUES (NULL, '" . $trans['amount'] . "', '0', '0', '3', '" . $trans['txid'] . "', " . (time()) . ");");
print($trans['amount'] + " - Payment has been sent to you!\n");
continue;
}
}
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `tx` = "'.$trans['txid'].'";');
if (!mysqli_fetch_assoc($query)) // Transaction not found in DB
{
$amount = $trans['amount'];
$topay = $amount * (1.0 + $config['income']);
print("Transaction added! [" . $amount . "]\n");
echo ("<br>");
$address = getAddress($trans);
mysqli_query($mysqli,"INSERT INTO `transactions` (`id`, `amount`, `topay`, `address`, `state`, `tx`, `date`) VALUES (NULL, '" . $amount . "', '" . $topay . "', '" . $address . "', '0', '" . $trans['txid'] . "', " . (time()) . ");");
}
}
// }
$query = mysqli_query($mysqli,"SELECT SUM(amount) FROM `transactions`;");
$query = mysqli_fetch_row($query);
$money = $query[0];
$query = mysqli_query($mysqli,"SELECT SUM(topay) FROM `transactions` WHERE `state` > 0;");
$query = mysqli_fetch_row($query);
$money -= $query[0];
$query = mysqli_query($mysqli,"SELECT * FROM `transactions` WHERE `state` = 0 AND `topay` > 0 ORDER BY `id` ASC;");
while($row = mysqli_fetch_assoc($query))
{
echo ("<br>");
print("Money: " . $money . "\n");
if ($money < $row['topay'])
break;
mysqli_query($mysqli,"UPDATE `transactions` SET `state` = 1 WHERE `id` = " . $row['id'] . ";");
$money -= $row['topay'];
}
echo ("<br>");
echo ("Waiting...\n");
Bonjour a tous.
quelqu'un pourrait me aider?
je suis très débutant et je ne arrive pas toujours le même erreur :-(
[php]include('config.php');
require_once 'easybitcoin.php';
$client = new Bitcoin($rpc['login'] , $rpc['password'] , $rpc['ip'] , $rpc['port']) or die('Error: could not connect to RPC server.');
$lastPayout = time();
$adresses = array();
function getAddress($trans)
{
global $client;
$address = "";
$details = $client->getrawtransaction($trans["txid"], 1);
$vintxid = $details['vin'][0]['txid'];
$vinvout = $details['vin'][0]['vout'];
try {
$transactionin = $client->getrawtransaction($vintxid, 1);
}
catch (Exception $e) {
die("Error with getting transaction details.\nYou should add 'txindex=1' to your .conf file and then run the daemon with the -reindex parameter.");
}
if ($vinvout == 1)
$vinvout = 0;
else
$vinvout = 1;
$address = $transactionin['vout'][!$vinvout]['scriptPubKey']['addresses'][0];
return $address;
echo $address;
}
// Paying out
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `state` = 1 ORDER BY `date` ASC;');
if (mysqli_fetch_assoc($query)) {
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `state` = 1 ORDER BY `date` ASC;');
while($row = mysqli_fetch_assoc($query))
{
if ($row['date'] + $config['payout-check'] < time()) {
$txout = $client->sendfrom($config['ponziacc'], $row['address'], round((float)$row['topay'], 4) - ($row['amount'] * $config['fee']));
mysqli_query($mysqli,"UPDATE `transactions` SET `state` = 2, `out` = '" . $txout . "' WHERE `id` = " . $row['id'] . ";");
print("Paying:<br>");
print($row['topay'] . " " . $config['val'] ." sent to " . $row['address'] . ".\n");
echo ("<br>");
}
}
}
// Parsing and adding new transactions to database
print("Parsing transactions...\n");
echo ("<br>");
$transactions = $client->listtransactions($config['ponziacc'], 100);
$i = 0;
// if (getAddress($transactions))
// {
foreach ($transactions as $trans)
{
echo("" . ++$i . ",\n");
if ($trans['category'] != "receive" || $trans["confirmations"] < $config['confirmations'])
continue;
if ($trans['amount'] > $config['max'] || $trans['amount'] < $config['min'])
{
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `tx` = "'.$trans['txid'].'";');
echo $query;
if (!mysqli_fetch_assoc($query))
{
if ($trans['amount'] < 0)
continue;
if ($config['sendback'])
$client->sendtoaddress(getAddress($trans), $trans['amount'] - ($trans['amount'] * $config['fee']));
else
$client->sendtoaddress($config['ownaddress'], $trans['amount'] - ($trans['amount'] * $config['fee']));
mysqli_query($mysqli,"INSERT INTO `transactions` (`id`, `amount`, `topay`, `address`, `state`, `tx`, `date`) VALUES (NULL, '" . $trans['amount'] . "', '0', '0', '3', '" . $trans['txid'] . "', " . (time()) . ");");
print($trans['amount'] + " - Payment has been sent to you!\n");
continue;
}
}
$query = mysqli_query($mysqli,'SELECT * FROM `transactions` WHERE `tx` = "'.$trans['txid'].'";');
if (!mysqli_fetch_assoc($query)) // Transaction not found in DB
{
$amount = $trans['amount'];
$topay = $amount * (1.0 + $config['income']);
print("Transaction added! [" . $amount . "]\n");
echo ("<br>");
$address = getAddress($trans);
mysqli_query($mysqli,"INSERT INTO `transactions` (`id`, `amount`, `topay`, `address`, `state`, `tx`, `date`) VALUES (NULL, '" . $amount . "', '" . $topay . "', '" . $address . "', '0', '" . $trans['txid'] . "', " . (time()) . ");");
}
}
// }
$query = mysqli_query($mysqli,"SELECT SUM(amount) FROM `transactions`;");
$query = mysqli_fetch_row($query);
$money = $query[0];
$query = mysqli_query($mysqli,"SELECT SUM(topay) FROM `transactions` WHERE `state` > 0;");
$query = mysqli_fetch_row($query);
$money -= $query[0];
$query = mysqli_query($mysqli,"SELECT * FROM `transactions` WHERE `state` = 0 AND `topay` > 0 ORDER BY `id` ASC;");
while($row = mysqli_fetch_assoc($query))
{
echo ("<br>");
print("Money: " . $money . "\n");
if ($money < $row['topay'])
break;
mysqli_query($mysqli,"UPDATE `transactions` SET `state` = 1 WHERE `id` = " . $row['id'] . ";");
$money -= $row['topay'];
}
echo ("<br>");
echo ("Waiting...\n");[/php]