elonmusk commited on
Commit
ef8c943
·
verified ·
1 Parent(s): 7d588b3

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +7 -0
  2. addresses.txt +0 -0
  3. index.js +120 -0
  4. package.json +14 -0
Dockerfile ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ FROM node:18
2
+ WORKDIR /app
3
+ COPY package.json .
4
+ RUN npm install
5
+ COPY . .
6
+ EXPOSE 7860
7
+ CMD ["node", "index.js"]
addresses.txt ADDED
The diff for this file is too large to render. See raw diff
 
index.js ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const fs = require('fs');
2
+ const express = require('express');
3
+ const bip39 = require('bip39');
4
+ const ecc = require('tiny-secp256k1');
5
+ const { BIP32Factory } = require('bip32');
6
+ const bip32 = BIP32Factory(ecc);
7
+ const bitcoin = require('bitcoinjs-lib');
8
+ const TelegramBot = require('node-telegram-bot-api');
9
+
10
+ const app = express();
11
+ const port = process.env.PORT || 7860;
12
+
13
+ const botToken = process.env.BOT_TOKEN;
14
+ const chatId = process.env.CHAT_ID;
15
+ const bot = new TelegramBot(botToken);
16
+
17
+ app.use(express.json());
18
+ app.use(express.urlencoded({ extended: true }));
19
+
20
+ let isGenerating = false;
21
+
22
+ app.get('/', (req, res) => {
23
+ res.send(`
24
+ <h1>Bitcoin Address Generator</h1>
25
+ <button onclick="startGeneration()" ${isGenerating ? 'disabled' : ''}>Generate</button>
26
+ <p>Status: ${isGenerating ? 'Generating addresses...' : 'Idle'}</p>
27
+ <script>
28
+ async function startGeneration() {
29
+ const response = await fetch('/generate', { method: 'POST' });
30
+ const result = await response.text();
31
+ alert(result);
32
+ location.reload();
33
+ }
34
+ </script>
35
+ `);
36
+ });
37
+
38
+ app.post('/generate', async (req, res) => {
39
+ if (isGenerating) {
40
+ return res.send('Generation already in progress');
41
+ }
42
+
43
+ isGenerating = true;
44
+
45
+ // Send Telegram notification when generation starts
46
+ bot.sendMessage(chatId, 'Address generation started.')
47
+ .catch(err => console.error('Failed to send start notification:', err.message));
48
+
49
+ res.send('Generation started. Check Telegram for any matches.');
50
+
51
+ const addressList = readAddressesFromFile();
52
+
53
+ // Run generation loop until stopped
54
+ while (isGenerating) {
55
+ try {
56
+ const mnemonic = bip39.generateMnemonic(128);
57
+ const seed = bip39.mnemonicToSeedSync(mnemonic);
58
+ const network = bitcoin.networks.bitcoin;
59
+ const root = bip32.fromSeed(seed, network);
60
+ const account = root.derivePath("m/84'/0'/0'/0");
61
+ const addressNode = account.derive(0);
62
+ const publicKey = addressNode.publicKey;
63
+
64
+ const { address: bech32Address } = bitcoin.payments.p2wpkh({ pubkey: publicKey, network });
65
+ const p2pkhAddress = bitcoin.payments.p2pkh({ pubkey: publicKey, network }).address;
66
+
67
+ const addressInfo = `
68
+ Mnemonic: ${mnemonic}
69
+ Bech32 SegWit Address: ${bech32Address}
70
+ P2PKH Address: ${p2pkhAddress}
71
+ `;
72
+
73
+ if (addressList.includes(bech32Address) || addressList.includes(p2pkhAddress)) {
74
+ sendAddressInfoToBot(addressInfo);
75
+ }
76
+
77
+ // Prevent CPU overload
78
+ await new Promise(resolve => setTimeout(resolve, 0));
79
+ } catch (error) {
80
+ console.error('Error during generation:', error.message);
81
+ bot.sendMessage(chatId, `Error during generation: ${error.message}`)
82
+ .catch(err => console.error('Failed to send error notification:', err.message));
83
+ }
84
+ }
85
+ });
86
+
87
+ function readAddressesFromFile() {
88
+ try {
89
+ if (!fs.existsSync('addresses.txt')) {
90
+ fs.writeFileSync('addresses.txt', '');
91
+ }
92
+ const addresses = fs.readFileSync('addresses.txt', 'utf-8').split('\n').map(address => address.trim());
93
+ return addresses.filter(Boolean);
94
+ } catch (error) {
95
+ console.error('Error reading addresses.txt:', error.message);
96
+ return [];
97
+ }
98
+ }
99
+
100
+ function sendAddressInfoToBot(info) {
101
+ bot.sendMessage(chatId, info)
102
+ .catch(err => console.error('Failed to send address notification:', err.message));
103
+ }
104
+
105
+ // Handle server shutdown gracefully
106
+ process.on('SIGTERM', () => {
107
+ isGenerating = false;
108
+ console.log('Server shutting down');
109
+ process.exit(0);
110
+ });
111
+
112
+ process.on('SIGINT', () => {
113
+ isGenerating = false;
114
+ console.log('Server interrupted');
115
+ process.exit(0);
116
+ });
117
+
118
+ app.listen(port, () => {
119
+ console.log(`Server started on port ${port}`);
120
+ });
package.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "crypto-address-generator",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "dependencies": {
6
+ "express": "^4.18.2",
7
+ "bip39": "^3.0.4",
8
+ "tiny-secp256k1": "^2.2.1",
9
+ "bip32": "^4.0.0",
10
+ "bitcoinjs-lib": "^6.0.2",
11
+ "node-telegram-bot-api": "^0.66.0",
12
+ "prompt-sync": "^4.2.0"
13
+ }
14
+ }