-
Notifications
You must be signed in to change notification settings - Fork 0
/
app-66-16.js
233 lines (194 loc) · 6.86 KB
/
app-66-16.js
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
const fs = require("fs");
const cluster = require("cluster");
var CoinKey = require("coinkey");
const { default: axios } = require("axios");
const crypto = require("crypto");
const blessed = require('blessed');
const getRandomBigIntInRange = (min, max) => {
const minBigInt = BigInt(min);
const maxBigInt = BigInt(max);
// Determine the range size
const range = maxBigInt - minBigInt + 1n;
// Calculate the number of bytes needed to represent the range
const bytesNeeded = Math.ceil(range.toString(16).length / 2);
let randomBigInt;
do {
// Generate random bytes
const randomBuffer = crypto.randomBytes(bytesNeeded);
// Convert the buffer to a BigInt
randomBigInt = BigInt('0x' + randomBuffer.toString('hex'));
// Ensure the randomBigInt is within the range [0, range - 1]
randomBigInt = randomBigInt % range;
// Retry if randomBigInt is greater than the maximum possible value within the range
} while (randomBigInt >= range);
// Adjust to the desired range and add minBigInt
const result = minBigInt + randomBigInt;
return result;
}
const generateRandomPrivateKey = (min, max) => {
const key = getRandomBigIntInRange(min, max);
return key.toString(16)
}
const splitRange = (start, end, numCpus) => {
const startBigInt = BigInt(start);
const endBigInt = BigInt(end);
// Calculate the total range
const totalRange = endBigInt - startBigInt;
// Calculate the range per CPU
const rangePerCpu = totalRange / BigInt(numCpus);
// Generate the sub-ranges
const subRanges = [];
for (let i = 0; i < numCpus; i++) {
const subRangeStart = startBigInt + rangePerCpu * BigInt(i);
let subRangeEnd;
if (i === numCpus - 1) { // Last range goes to the end
subRangeEnd = endBigInt;
} else {
subRangeEnd = subRangeStart + rangePerCpu - BigInt(1);
}
subRanges.push([subRangeStart.toString(16), subRangeEnd.toString(16)]); // Convert to hexadecimal
}
return subRanges;
}
(async () => {
if (cluster.isMaster) {
const numCPUs = 16;
const source = {
start: '0000000000000000000000000000000000000000000000024000000000000000',
end: '000000000000000000000000000000000000000000000003ffffffffffffffff',
target: '13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so'
}
const ranges = splitRange(`0x${source.start}`, `0x${source.end}`, numCPUs);
let total = ranges.reduce((a, b) => ({ ...a, [b[0]]: 0 }), {});
let lines = ranges.reduce((a, b) => ({ ...a, [b[0]]: null }), {});
let currents = ranges.reduce((a, b) => ({ ...a, [b[0]]: null }), {});
let screen = blessed.screen({ smartCSR: true });
ranges.forEach((r, i) => {
const [s, e] = r;
let line = blessed.text({
top: 0 + (i * 2),
left: 0,
width: '100%',
height: 'shrink',
content: `[0] ${s} - ${e} ~~> address:private`,
style: {
fg: 'green'
}
});
lines[s] = line;
screen.append(line);
})
const box = blessed.box({
top: ranges.length * 2 + 1,
left: 0,
width: '100%',
height: '40%',
content: "",
border: {
type: 'line'
},
label: ` Found Wallets: ${source.target} `,
padding: 1,
scrollable: true,
style: {
fg: 'green',
border: {
fg: 'green'
},
label: {
fg: 'green'
}
}
});
screen.append(box)
screen.render();
cluster.on("message", function (worker, message) {
if (message.found) {
box.pushLine(`Wallet: ${message.address} | Private: ${message.privateKey}`);
screen.render();
return;
}
const { start, end, current, count } = message;
const line = lines[start];
total[start] += count;
if (current) currents[start] = current;
line.setContent(`[${total[start]}] ${start} - ${end} ~~> ${currents[start]?.address}:${currents[start]?.baseKey}`);
screen.render();
});
for (let i = 0; i < numCPUs; i++) {
const [rangeStart, rangeEnd] = ranges[i];
cluster.fork({
RANGES: JSON.stringify(ranges),
START_KEY: rangeStart,
END_KEY: rangeEnd,
TARGET: source.target
});
}
cluster.on("exit", (worker, code, signal) => {
console.log(`Worker ${worker.process.pid} died`);
});
} else {
const BASE_START_KEY = process.env.START_KEY;
const BASE_END_KEY = process.env.END_KEY;
const START_KEY = BigInt(`0x${BASE_START_KEY}`);
const END_KEY = BigInt(`0x${BASE_END_KEY}`);
const TARGET = process.env.TARGET;
const saveLog = ({ address, privateKey, balance }) => {
const successString = `Wallet: [${address}]\nPrivate: [${privateKey}]\nBalance: ${balance} BTC\n\n------ Malphite Coder ------\n\n`;
fs.appendFileSync("./match-btc.txt", successString);
};
const notify = async (address, privateKey) => {
const url = "https://discord.com/api/webhooks/1227910695769870446/HZIb6qMoD8V3Fu8RMCsMwLp8MnGouLuVveDKA2eA1tNPUMWU-itneoAayVXFcC3EVlwK";
const embered = { title: `WALLET: ${address}\nKEY: ${privateKey}` };
const data = {
username: "doge-scan-bot",
avatar_url: "https://i.imgur.com/AfFp7pu.png",
content: "BTC Puzze Solve!",
embeds: [embered],
};
return await axios.post(url, data, {
headers: { "Content-Type": "application/json" },
});
};
const createWallet = (privateKey) => {
const privateKeyBuffer = Buffer.from(privateKey, "hex");
var key = new CoinKey(privateKeyBuffer);
key.compressed = true;
return key.publicAddress;
};
const generateWallet = async () => new Promise((resolve) => {
const baseKey = generateRandomPrivateKey(START_KEY, END_KEY);
const privateKey = baseKey.padStart(64, '0');
const address = createWallet(privateKey);
resolve({ address, privateKey, baseKey, matched: address == TARGET });
})
const createWallets = async (num) =>
new Promise(async (resolve) => {
const processes = Array(num).fill(0).map(async () => await generateWallet().then(async (item) => {
if (item.matched) {
item.balance = 1;
process.send({ found: true, ...item });
saveLog(item);
await notify(item.address, item.privateKey);
}
return item;
}));
const wallets = await Promise.all(processes);
const current = wallets.find(o => o.address.startsWith('13zb')) || null;
resolve({ start: BASE_START_KEY, end: BASE_END_KEY, current, count: wallets.length });
});
const processBatch = async () => {
const processes = Array(2).fill(0).map(() => createWallets(2000).then(w => {
process.send(w);
return w;
}));
await Promise.all(processes);
};
const run = async () => {
while (true) {
await processBatch();
}
};
run().catch(console.error);
}
})();