This repository has been archived by the owner on Dec 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_bitcoin.php
62 lines (53 loc) · 1.7 KB
/
test_bitcoin.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
function __autoload($class)
{
include_once('includes/'.$class.'.class.php');
}
?>
<html>
<head>
<title>BitcoinShop suite test page</title>
</head>
<body>
<?php
$sys=new BitcoinSystem('http://rpcuser:password@localhost:18332');
?>
<h3>System information - BitcoinSystem class</h3>
<table border>
<tr><td>Overall balance</td><td><?php echo $sys->getBalance(); ?></td></tr>
<tr><td>SysInfo</td><td><pre><?php print_r($sys->getInfo()); ?></pre></td></tr>
</table>
<?php
$bc=new BitcoinAccount('http://rpcuser:password@localhost:18332');
?>
<h3>System account - BitcoinAccount class</h3>
<table border>
<tr><td>Default system address</td><td><?php echo $bc->getAddress(); ?></td></tr>
<tr><td>All system addresses</td><td><pre><?php print_r($bc->getAddressList());?></pre></td></tr>
<tr><td>System balance</td><td><?php echo $bc->getBalance(); ?></td></tr>
</table>
<?php
$tt=new BitcoinUser('http://rpcuser:password@localhost:18332','TEST');
?>
<h3>"TEST" user account - BitcoinUser class</h3>
<table border>
<tr><td>Default address</td><td><?php echo $tt->getAddress(); ?></td></tr>
<tr><td>All account addresses</td><td><pre><?php print_r($tt->getAddressList());?></pre></td></tr>
<tr><td>Balance</td><td><?php echo $tt->getBalance(); ?></td></tr>
</table>
<?php
$tt->take(0.01);
?>
<h3>Take coins from "TEST": 0.01</h3>
<table border>
<tr><td>System balance</td><td><?php echo $bc->getBalance(); ?></td></tr>
<tr><td>"TEST" balance</td><td><?php echo $tt->getBalance(); ?></td></tr>
</table>
<?php
$tt->give(0.01);
?>
<h3>Give coins to "TEST": 0.01</h3>
<table border>
<tr><td>System balance</td><td><?php echo $bc->getBalance(); ?></td></tr>
<tr><td>"TEST" balance</td><td><?php echo $tt->getBalance(); ?></td></tr>
</table>