forked from shubhamkhanna161295/recordskeeper-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreaterawsendfrom.php
executable file
·62 lines (62 loc) · 2.02 KB
/
createrawsendfrom.php
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
$net = $_POST['net'];
if ($net == 'TestNetwork'){
$config = include('config-testnet.php');}
else {
$config = include('config-mainnet.php');
}
$chain = $config['chain'];
$curl = curl_init();
$addr = $_POST['from'];
$key = $_POST['key'];
$val = $_POST['val'];
$to = $_POST['to'];
$amount =$_POST['amount'];
if($key == "" && $val == ""){
curl_setopt_array($curl, array(
CURLOPT_PORT => $config['rk_port'],
CURLOPT_URL => $config['rk_host'],
CURLOPT_USERPWD => $config['rk_user'].":".$config['rk_pass'],
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"method\":\"createrawsendfrom\",\"params\":[\"$addr\",{\"$to\":$amount},[]],\"id\":\"curltext\",\"chain_name\":\"$chain\"}",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/json",
"Postman-Token: a04df090-2ea9-9b78-e373-c71b54d8b41b"
),
));
}
else{
curl_setopt_array($curl, array(
CURLOPT_PORT => $config['rk_port'],
CURLOPT_URL => $config['rk_host'],
CURLOPT_USERPWD => $config['rk_user'].":".$config['rk_pass'],
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"method\":\"createrawsendfrom\",\"params\":[\"$addr\",{\"$to\":$amount},[{\"for\":\"root\",\"key\":\"$key\",\"data\":\"$val\"}]],\"id\":\"curltext\",\"chain_name\":\"$chain\"}",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/json",
"Postman-Token: a04df090-2ea9-9b78-e373-c71b54d8b41b"
),
));
}
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}