-
Notifications
You must be signed in to change notification settings - Fork 99
/
page-send.php
183 lines (162 loc) · 5.56 KB
/
page-send.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
if (@$_POST['unlockoutputs'])
if (no_displayed_error_result($result, multichain('lockunspent', true)))
output_success_text('All outputs successfully unlocked');
if (@$_POST['sendasset']) {
if (strlen($_POST['metadata']))
$success=no_displayed_error_result($sendtxid, multichain('sendwithmetadatafrom',
$_POST['from'], $_POST['to'], array($_POST['asset'] => floatval($_POST['qty'])), bin2hex($_POST['metadata'])));
else
$success=no_displayed_error_result($sendtxid, multichain('sendassetfrom',
$_POST['from'], $_POST['to'], $_POST['asset'], floatval($_POST['qty'])));
if ($success)
output_success_text('Asset successfully sent in transaction '.$sendtxid);
}
?>
<div class="row">
<div class="col-sm-5">
<h3>Available Balances</h3>
<?php
$sendaddresses=array();
$usableaddresses=array();
$keymyaddresses=array();
$keyusableassets=array();
$haslocked=false;
$getinfo=multichain_getinfo();
$labels=array();
if (no_displayed_error_result($getaddresses, multichain('getaddresses', true))) {
if (no_displayed_error_result($listpermissions,
multichain('listpermissions', 'send', implode(',', array_get_column($getaddresses, 'address')))
))
$sendaddresses=array_get_column($listpermissions, 'address');
foreach ($getaddresses as $address)
if ($address['ismine'])
$keymyaddresses[$address['address']]=true;
$labels=multichain_labels();
if (no_displayed_error_result($listpermissions, multichain('listpermissions', 'receive')))
$receiveaddresses=array_get_column($listpermissions, 'address');
foreach ($sendaddresses as $address) {
if (no_displayed_error_result($allbalances, multichain('getaddressbalances', $address, 0, true))) {
if (count($allbalances)) {
$assetunlocked=array();
if (no_displayed_error_result($unlockedbalances, multichain('getaddressbalances', $address, 0, false))) {
if (count($unlockedbalances))
$usableaddresses[]=$address;
foreach ($unlockedbalances as $balance)
$assetunlocked[$balance['name']]=$balance['qty'];
}
$label=@$labels[$address];
?>
<table class="table table-bordered table-condensed table-break-words <?php echo ($address==@$getnewaddress) ? 'bg-success' : 'table-striped'?>">
<?php
if (isset($label)) {
?>
<tr>
<th style="width:25%;">Label</th>
<td><?php echo html($label)?></td>
</tr>
<?php
}
?>
<tr>
<th style="width:20%;">Address</th>
<td class="td-break-words small"><?php echo html($address)?></td>
</tr>
<?php
foreach ($allbalances as $balance) {
$unlockedqty=floatval($assetunlocked[$balance['name']]);
$lockedqty=$balance['qty']-$unlockedqty;
if ($lockedqty>0)
$haslocked=true;
if ($unlockedqty>0)
$keyusableassets[$balance['name']]=true;
?>
<tr>
<th><?php echo html($balance['name'])?></th>
<td><?php echo html($unlockedqty)?><?php echo ($lockedqty>0) ? (' ('.$lockedqty.' locked)') : ''?></td>
</tr>
<?php
}
?>
</table>
<?php
}
}
}
}
if ($haslocked) {
?>
<form class="form-horizontal" method="post" action="./?chain=<?php echo html($_GET['chain'])?>&page=<?php echo html($_GET['page'])?>">
<input class="btn btn-default" type="submit" name="unlockoutputs" value="Unlock all outputs">
</form>
<?php
}
?>
</div>
<div class="col-sm-7">
<h3>Send Asset</h3>
<form class="form-horizontal" method="post" action="./?chain=<?php echo html($_GET['chain'])?>&page=<?php echo html($_GET['page'])?>">
<div class="form-group">
<label for="from" class="col-sm-3 control-label">From address:</label>
<div class="col-sm-9">
<select class="form-control" name="from" id="from">
<?php
foreach ($usableaddresses as $address) {
?>
<option value="<?php echo html($address)?>"><?php echo format_address_html($address, true, $labels)?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="asset" class="col-sm-3 control-label">Asset name:</label>
<div class="col-sm-9">
<select class="form-control" name="asset" id="asset">
<?php
foreach ($keyusableassets as $asset => $dummy) {
?>
<option value="<?php echo html($asset)?>"><?php echo html($asset)?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="to" class="col-sm-3 control-label">To address:</label>
<div class="col-sm-9">
<select class="form-control" name="to" id="to">
<?php
foreach ($receiveaddresses as $address) {
if ($address==$getinfo['burnaddress'])
continue;
?>
<option value="<?php echo html($address)?>"><?php echo format_address_html($address, @$keymyaddresses[$address], $labels)?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="qty" class="col-sm-3 control-label">Quantity:</label>
<div class="col-sm-9">
<input class="form-control" name="qty" id="qty" placeholder="0.0">
</div>
</div>
<!--<div class="form-group">
<label for="metadata" class="col-sm-3 control-label">Metadata:</label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" name="metadata" id="metadata"></textarea>
</div>
</div>-->
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<input class="btn btn-default" type="submit" name="sendasset" value="Send Asset">
</div>
</div>
</form>
</div>
</div>