-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.00.insight.html
277 lines (243 loc) · 6.54 KB
/
tool.00.insight.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
<html>
<body>
<script src="js/csv.js"></script>
<style>
td {
padding-left:8px;
}
.centered {
position:absolute;
left:50%;
top:50%;
transform:translate(-50%,-50%);
}
.backdrop {
position:absolute;
left:0px;
top:0px;
width:100%;
height:100%;
display:none;
background-color:rgba(0,0,0,0.5);
}
.dialog {
border-radius:5px;
background-color:white;
padding:8px;
}
</style>
<div id="addAddressDialog" class="backdrop">
<div class="centered dialog">
<div style="margin-bottom:9px">Add Bitcoin Public Address</div>
<table style="margin-bottom:9px"><tbody>
<tr><td>Name</td><td><input type="text" style="width:23em" id="name"></td></tr>
<tr><td>Address</td><td><input type="text" style="width:23em" id="address"></td></tr>
</tbody></table>
<div>
<button style="float:right" onclick="cancelAddAddress()">Cancel</button>
<button style="float:right; margin-right:9px;" onclick="doneAddAddress()">Okay</button></div>
</div>
</div>
This tool generates links to download transactions for bitcoin addresses.<br>
<br>
1) Start by adding your bitcoin public addresses at the bottom. You can save your list of addresses to quickly reopen them in the future.<br>
<br>
2) Next choose where you want to download the transaction json files from (default is random): <br>
<form id="sourceSelect">
</form>
3) Next press Generate All.<br>
<br>
4) Finally download each link (right click and choose save as) for firefox you need to manually name the wallet files as bitcoin_address.json where bitcoin_address should be replaced with the actual address.<br>
<br>
<button onclick="queryAddAddress()">Add Address...</button>
<button onclick="queryAddressFile()">Load...</button>
<button id="saveButton" disabled onclick="saveAddressFile()">Save</button>
<button id="generateAllButton" disabled onclick="generateAll()">Generate All</button>
<a></a>
<br>
<table>
<tbody id="addressTable">
<tr><td>Name</td><td>Address</td><td>Actions</td><td>Link</td></tr>
</tbody>
</table>
<script>
var tbody = document.getElementById('addressTable');
var addAddressDialog = document.getElementById('addAddressDialog');
var addAddressName = addAddressDialog.querySelector('#name');
var addAddressAddress = addAddressDialog.querySelector('#address');
var saveButton = document.getElementById('saveButton');
var generateAllButton = document.getElementById('generateAllButton');
var link = document.querySelector('a');
var addresses = []
var insightSites = [
'blockexplorer.com',
'insight.bitpay.com',
'localbitcoinschain.com',
// 'search.bitaccess.ca',
];
var sourceSelect = document.getElementById('sourceSelect');
sourceSelect.insertAdjacentHTML('beforeend', '<input type="radio" name="source" value="random" checked>random<br>');
for (var i = 0; i < insightSites.length; i++)
{
var site = insightSites[i];
sourceSelect.insertAdjacentHTML('beforeend', '<input type="radio" name="source" value="' + site + '">' + site + '<br>');
}
sourceSelect.insertAdjacentHTML('beforeend', '<input type="radio" name="source" value="custom">private insight server: <input type="text" id="insightURL">');
function generateLink(address)
{
var value = sourceSelect.elements['source'].value
address.link = 'https://';
switch (value)
{
case 'random':
address.link += insightSites[Math.trunc(Math.random()*insightSites.length)];
break;
case 'custom':
address.link += document.getElementById('insightURL').value;
break;
default:
address.link += value;
}
address.link += '/api/txs/?address=' + address.address;
}
function getAddressLink(address)
{
return address.link? '<a href="' + address.link + '" download="' + address.address + '.json">' + address.link + '</a>' : '';
}
function trGetCol(tr, index)
{
while (index >= tr.children.length)
{
var td = document.createElement('td');
tr.appendChild(td);
}
return tr.children[index];
}
function trCreateCol(tr, textContent)
{
var td = document.createElement('td');
td.textContent = textContent;
tr.appendChild(td);
}
function trCreateActionButtons(tr, address)
{
var td = trGetCol(tr, 2);
var button = document.createElement('button');
button.textContent = 'Remove';
button.onclick = function ()
{
if (confirm('are you sure you want to remove ' + address.name))
{
tbody.removeChild(tr);
var index = addresses.indexOf(address);
addresses.splice(index, 1);
if (addresses.length == 0)
{
saveButton.disabled = true;
generateAllButton.disabled = true;
}
}
}
td.appendChild(button);
var button = document.createElement('button');
button.textContent = 'Generate';
button.onclick = function ()
{
generateLink(address);
trGetCol(tr, 3).innerHTML = getAddressLink(address);
}
td.appendChild(button);
}
function bindAddressToTable(address)
{
var tr = document.createElement('tr');
trGetCol(tr, 0).textContent = address.name;
trGetCol(tr, 1).textContent = address.address;
trCreateActionButtons(tr, address);
trGetCol(tr, 3).innerHTML = getAddressLink(address);
tbody.appendChild(tr);
}
//
// Load
//
function loadedAddressFile()
{
addresses = JSON.parse(this.result);
while (tbody.children.length > 1)
{
tbody.removeChild(tbody.lastElementChild);
}
for (var i = 0; i < addresses.length; i++)
{
bindAddressToTable(addresses[i]);
}
saveButton.disabled = false;
generateAllButton.disabled = false;
}
function loadAddressFile()
{
var reader = new FileReader();
reader.onload = loadedAddressFile;
reader.readAsText(this.files[0]);
}
var inputLoad = document.createElement('input');
inputLoad.type = 'file';
inputLoad.onchange = loadAddressFile;
function queryAddressFile()
{
inputLoad.value = '';
inputLoad.click();
}
//
// Save
//
var aSave = document.querySelector('a');
aSave.download = 'addresses.json';
function saveAddressFile()
{
aSave.textContent = 'addresses.json';
//aSave.href = 'data:text/json;charset=UTF-8,' + encodeURIComponent(JSON.stringify(addresses));
aSave.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(addresses));
aSave.click();
}
//
// Add Address
//
function queryAddAddress()
{
addAddressDialog.style.display='block';
}
function cancelAddAddress()
{
addAddressDialog.style.display='none';
}
function doneAddAddress()
{
addAddressDialog.style.display='none';
var address = {
name : addAddressName.value,
address : addAddressAddress.value,
};
addresses.push(address);
bindAddressToTable(address);
saveButton.disabled = false;
generateAllButton.disabled = false;
}
//
// Update All
//
function generateAll()
{
for (var i = 1; i < tbody.children.length; i++)
{
var tr = tbody.children[i];
if (tr.children.length < 4)
{
continue;
}
trGetCol(tr, 2).children[1].click();
}
}
</script>
</body>
</html>