-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathwithdraw code pure
127 lines (105 loc) · 5.92 KB
/
withdraw code pure
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//begin mysql
$servername = "localhost";
$username = "username";
$password = "pass";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT username,address FROM strm_members WHERE username='".$_SESSION['username']."' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$address1 = $row["address"];
$da8 = array("method" => "getBalance", "params" => array('address' => $address1));
//$dat = array("method" => "createAddress");
$da8_string = json_encode($da8);
$kech8 = curl_init('http://localhost:8070/json_rpc');
curl_setopt($kech8, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($kech8, CURLOPT_POSTFIELDS, $da8_string);
curl_setopt($kech8, CURLOPT_RETURNTRANSFER, true);
curl_setopt($kech8, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($da8_string))
);
//echo $da8_string;
$result8 = curl_exec($kech8);
//echo $result8;
$det8 = json_decode($result8, true);
$balance = $det8['result']['availableBalance'];
$normalbalance = $balance / "100000000000";
echo ' <div class="col-lg-2"></div><div class="col-lg-8">
<form id="mailform" action="withdraw.php" method="post">
<h3>minimum fee is 0.01</h3>
<label id="amount"> amount:</label><br/>
<input type="text" name="amount"><br/>
<label id="fee">Fee:</label><br/>
<input type="text" name="fee"><br/>
<label id="receive">Receive address:</label><br/>
<input type="text" name="receive"><br/>
<button class="btn btn-lg btn-primary btn-block" style="margin-top: 26px;" type="submit" name="save1">Withdraw your StreamCoins!</button>';
echo '<h3> Your current confirmed balance:'; echo $normalbalance; echo '</h3>';
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
// something posted
if (isset($_POST['save1']))
{
// btnDelete
$amountbig = $_POST["amount"];
$amount = $amountbig * "100000000000";
$feebig = $_POST["fee"];
$fee = $feebig * "100000000000";
$receive = $_POST["receive"];
echo $amount;
echo $receive;
$address1 = $row["address"];
echo $address1;
$da = array(
"method" => "sendTransaction",
"params" => array(
"anonymity" => 0,
"fee" => $fee,
"addresses" => array(
$address1
) ,
"transfers" => array(
array(
"amount" => $amount,
"address" => $receive
)
)
)
);
// $dat = array("method" => "createAddress");
$da_string = json_encode($da, JSON_NUMERIC_CHECK);
var_dump($da_string);
$kech2 = curl_init('http://localhost:8070/json_rpc');
curl_setopt($kech2, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($kech2, CURLOPT_POSTFIELDS, $da_string);
curl_setopt($kech2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($kech2, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($da_string)
));
$result2 = curl_exec($kech2);
// var_dump ($result2);
// echo $result2;
$det1 = json_decode($result2, true);
$output1 = $det1['result']['transactionHash'];
$errors = $det1['result']['error'];
echo '<h3 style="color:blue;">TransactionID:';
echo $output1;
echo '</h3>';
echo '<h3 style="color:red;">';
echo $errors;
echo '</h3>';
}
else
{
// assume btnSubmit
}
}