forked from zonedoutspace/BitWallet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
32 lines (27 loc) · 942 Bytes
/
send.php
File metadata and controls
32 lines (27 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
include("login.php");
require_once '/API/jsonRPCClient.php';
error_reporting(E_WARNING | E_PARSE);
$bitcoin = new jsonRPCClient('http://username:password@127.0.0.1:8332/') or die ("An error has occurred. Please try again.");
$amount=floatval(mysql_real_escape_string($_POST['amount']));
$receiver=mysql_real_escape_string($_POST['address']);
$accountbalance=$bitcoin->getbalance($_SESSION['username'],4);
$isvalid= $bitcoin->validateaddress($receiver);
// checking account balance and valid address
if ($isvalid['isvalid']==0)
{
die("Sending address is invalid.");
}
else if($accountbalance<$amount) // check if sufficient balance in user account
{
die("Insufficient funds in account.");
}
else if ($accountbalance>=$amount && $isvalid['isvalid']==1){
$bitcoin->sendfrom($_SESSION['username'],$receiver,$amount,3);
header("Location: sent.php");
}
else
{
die("An error has occurred.");
}
?>