function transfer($toAccount, $fromAccount, $amount)
{
    if (!debit($amount, $fromAccount)) {
        return false;
    }
    credit($amount, $toAccount);
    return true;
}
Ejemplo n.º 2
0
function sendBtc($id, $amount)
{
    #Send btc from id to address
    $bitcoin = new jsonRPCClient("http://{$bitcoin_user}:{$bitcoin_pass}@127.0.0.1:8332/");
    if ($bitcoin->getbalance() < $amount) {
        return -1;
    }
    if (!debit($id, $amount)) {
        return -2;
    }
    $address = getAddress($id);
    if ($address == -1) {
        return -3;
    }
    $comment = getUsernameById($id);
    $bitcoin->sendtoaddress($address, $amount, $comment);
    return 0;
}
<?php

require 'account.php';
session_start();
$amount = $_REQUEST['amount'];
$accNum = $_SESSION['debitNum'];
if (debit($amount, $accNum)) {
    header('Location: admin.php');
} else {
    header('Location: insufficientFunds.html');
}