forked from amjuarez/bytecoin
-
Notifications
You must be signed in to change notification settings - Fork 9
/
wallet.html
335 lines (282 loc) · 9.15 KB
/
wallet.html
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<title>DuckNote Wallet Wrapper</title>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<style>
.rpc-result {
font-size: large;
color: green;
}
</style>
<script language="javascript">
var max=0;
function textlist() {
max=textlist.arguments.length;
for (i=0; i<max; i++)
this[i]=textlist.arguments[i];
}
tl = new textlist(
"Follow the duck, stranger...",
"Das ist kleine duckNote GUI, nur browser erforderlich...",
"Internet, Browser & default duckNote ./simplewallet in JSON-RPC enabled mode is all you need.",
"Pure HTML and JavaScript here",
"First run your ducknoted, wait until it sync...",
"Than run your simplewallet in JSON-RPC enabled mode on 42082 port: ./simplewallet --wallet-file=WALLETFILE --password=PASSWORD --rpc-bind-port=42082",
"Wait until it sync...",
"Open that page in browser and be happy",
"Just copy source code of that page, custumize HTML to get your own styled GUI"
);
var x = 0; pos = 0;
var l = tl[0].length;
function textticker() {
document.tickform.tickfield.value = tl[x].substring(0, pos) + "_";
if(pos++ == l) {
pos = 0;
<!-- web-mastery.info -->
setTimeout("textticker()", 3000);
if(++x == max) x = 0;
l = tl[x].length;
} else
setTimeout("textticker()", 150);}
</script>
</head>
<body onload="textticker()">
<script>
function forceNumber(string) {
var anum = /(^\d+$)|(^\d+\.\d+$)/
if(typeof string == 'string' && anum.test(string)) {
string = Number(string);
}
return string;
}
$(function() {
$.fn.serializeObject = function() {
var self = this,
json = {},
push_counters = {},
patterns = {
"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
"push": /^$/,
"fixed": /^\d+$/,
"named": /^[a-zA-Z0-9_]+$/
};
this.build = function(base, key, value) {
base[key] = forceNumber(value);
return base;
};
this.push_counter = function(key) {
if(push_counters[key] === undefined) {
push_counters[key] = 0;
}
return push_counters[key]++;
};
$.each($(this).serializeArray(), function() {
if(!patterns.validate.test(this.name)) {
return;
}
var k,
keys = this.name.match(patterns.key),
merge = this.value,
reverse_key = this.name;
while((k = keys.pop()) !== undefined) {
reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
if(k.match(patterns.push)) {
merge = self.build([], self.push_counter(reverse_key), merge);
}
else if(k.match(patterns.fixed)) {
merge = self.build([], k, merge);
}
else if(k.match(patterns.named)) {
merge = self.build({}, k, merge);
}
}
json = $.extend(true, json, merge);
});
return json;
};
function parseNum(num) {
num = num.toString();
return num.substr(0, num.length - 8) + '.' + num.substr(-8);
}
function numToDuck(num) {
return num * 100000000;
}
function handleRequest(method, params) {
if(method == 'transfer') {
console.log('EE', params.destinations[0].amount, numToDuck(params.destinations[0].amount));
params.destinations[0].amount = numToDuck(params.destinations[0].amount);
params.fee = numToDuck(params.fee);
}
return params;
}
function handleResult(method, result, $resultNode) {
if(method == 'getbalance') {
console.log('R', $resultNode);
$resultNode.html('</br>Locked: ' + parseNum(result.balance) + ' </br> Unlocked: ' + parseNum(result.unlocked_balance));
}
else if(method == 'transfer') {
$resultNode.html('</br>Ok');
}
else if(method == 'store') {
$resultNode.html('</br>Ok');
}
}
function callRpc(method, paramsData, $resultNode) {
var url = 'http://' + $('#rpcHost').val() + ':' + $('#rpcPort').val() + '/json_rpc';
var request = {
"jsonrpc": "2.0",
"method": method,
"params": paramsData.params ? handleRequest(method, paramsData.params) : {}
};
console.log('RPC CALL', url, method, request);
$.ajax({
url: url,
type: 'POST',
cache: false,
data: JSON.stringify(request),
success: function(result) {
console.log('RPC RESULT', result);
handleResult(method, result.result, $resultNode);
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('RPC CALL FAILED', textStatus);
// alert('Request to ' + url + ' failed');
},
dataType: 'json'
});
}
$('.rpc-submit').click(function() {
var $baseNode = $(this).closest('.rpc-method');
var $resultNode = $baseNode.find('.rpc-result');
$resultNode.text('');
callRpc($(this).data('method'), $baseNode.serializeObject(), $resultNode);
return false;
});
});
</script>
</ul>
</br>
<div class="container">
<div class="row clearfix">
<div class="col-md-2 column">
</div>
<div class="col-md-8 column">
<h2>duckNote easy customizable single .html page GUI _0<</h2></marquee>
</div>
<div class="col-md-2 column">
</div>
</div>
</div>
<div class="container">
<div class="row clearfix">
<div class="col-md-2 column">
</div>
<div class="col-md-4 column">
<h5>
<div class="goscrpt">
<form class="form-horizontal">
<fieldset>
<div class="control-group">
<label class="control-label">Host</label>
<div class="controls">
<input id="rpcHost" name="textinput" placeholder="localhost" class="form-control" type="text" value="localhost">
<p class="help-block">Enter hostname of ./simplewallet.</p>
</div>
</div>
<div class="control-group">
<label class="control-label">Port</label>
<div class="controls">
<input id="rpcPort" class="form-control" name="textinput" placeholder="42082" type="text" value="42082">
<p class="help-block">Enter port of ./simplewallet JSON-RPC</p>
</div>
</div>
</fieldset>
</form>
<!-- BALANCE -->
<form class="form-horizontal rpc-method">
<fieldset>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<button name="singlebutton" class="btn btn-success btn-block rpc-submit" data-method="getbalance">Check Balance</button>
</div>
<div class="rpc-result"></div>
</div>
</fieldset>
</form>
<form class="form-horizontal rpc-method">
<fieldset>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<button name="singlebutton" class="btn btn-block btn-default rpc-submit" data-method="store">Store blockchain</button>
</div>
<div class="rpc-result"></div>
</div>
</fieldset>
</form>
</br>
</br>
<form name=tickform>
<textarea name=tickfield rows=6 cols=56 style="background-color:#000000; color:#66FF00; font-size:11px; overflow:hidden;" wrap=virtual>Loading ...</textarea>
</form>
</h5>
</div>
<div class="col-md-4 column">
<!-- TRANSFER -->
<h5>
<form class="form-horizontal rpc-method">
<fieldset>
<input type="hidden" name="params[mixin]" value="0" />
<input type="hidden" name="params[unlock_time]" value="0" />
<div class="control-group">
<label class="control-label">Transfer to</label>
<div class="controls">
<input name="params[destinations][0][address]" placeholder="Address" class="form-control" type="text">
<p class="help-block">Enter transfer destination address</p>
</div>
</div>
<div class="control-group">
<label class="control-label">Amount</label>
<div class="controls">
<input name="params[destinations][0][amount]" placeholder="Amount" class="form-control" type="text">
<p class="help-block">Enter amount to transfer</p>
</div>
</div>
<div class="control-group">
<label class="control-label">Fee</label>
<div class="controls">
<input name="params[fee]" placeholder="Fee" class="form-control" type="text" value="1">
<p class="help-block">Enter transfer fee</p>
</div>
</div>
<div class="control-group">
<label class="control-label">Mixin</label>
<div class="controls">
<input name="params[mixin]" placeholder="Mixin" class="form-control" type="text" value="0">
<p class="help-block">Enter mixin number. More mixes = more anonymity.</p>
</div>
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<button name="singlebutton" class="btn btn-block btn-primary rpc-submit" data-method="transfer">Transfer funds</button>
</div>
</div>
<div <div class="rpc-result"></div>
</fieldset>
</form>
</div>
<div class="col-md-2 column">
</div>
</div>
</div>
</h5>
</body>
</html>