-
Notifications
You must be signed in to change notification settings - Fork 8
/
withdraw.php
57 lines (42 loc) · 1.42 KB
/
withdraw.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
<?php
require_once __DIR__."/src/utils/WpUtil.php";
require_once __DIR__."/src/model/Transaction.php";
require_once __DIR__."/src/model/Account.php";
use wpblockchainaccounts\WpUtil;
use wpblockchainaccounts\Transaction;
use wpblockchainaccounts\Account;
require_once WpUtil::getWpLoadPath();
$account=Account::getCurrentUserAccount();
if (!$account)
return "<i>not logged in</i>";
try {
if (!$_REQUEST["address"])
throw new Exception("Please enter the address to withdraw to.");
if (!$_REQUEST["amount"])
throw new Exception("Please enter the amount to withdraw.");
$address=$_REQUEST["address"];
$amount=$_REQUEST["amount"];
$_REQUEST["address"]="";
$_REQUEST["amount"]="";
$t=$account->withdraw($_REQUEST["denomination"],$address,$amount);
switch ($t->getState()) {
case Transaction::COMPLETE:
$_SESSION["bca_withdraw_success"]=
"The withdrawal has been processed.";
break;
case Transaction::SCHEDULED:
$_SESSION["bca_withdraw_success"]=
"Your withdrawal has been initiated.<br/>".
"Please see your account history for progress.";
break;
default:
throw new Exception("Unknown transaction state.");
break;
}
}
catch (Exception $e) {
$_SESSION["bca_withdraw_error"]=$e->getMessage();
$_SESSION["bca_withdraw_address"]=$_REQUEST["address"];
$_SESSION["bca_withdraw_amount"]=$_REQUEST["amount"];
}
header("Location: ".$_REQUEST["afterWithdraw"]);