Generate and download thousands of Bitcoin wallets in a minute or two
A delicate script-twist that CREATE the “Download” function on bitaddress.org
This workshop article will take you through the process of twisting the code of bitaddress.org to hack in a Download button that ease your life of bulk Bitcoin wallet address generation. This article serves only for educational purpose and recognizes bitaddress.org as a great resource for Bitcoin developer community.
Disclaimer: The author has come across bitaddress.org on same the day that this article is written. Not an advertisement lol. :)
Go straight to repository (here), if you wanna skip class ;p
Step 1: Visit bitaddress.org
Go visit bitaddress.org, and you will see similar screen as below.
This website allows you to create single (or bulk) wallet addresses and also provides a variety of functionalities around Bitcoin wallet creation. You may now swing around your cursor to fill up the random seeding degree (e.g. the 6% thing on the screenshot).
Click on Bulk Wallet, as soon as it shows up on the green bar. You can now fill in any number in the Rows to generate section as the amount of wallets to be generated. By clicking the Generate button, the plaintext csv outputs in the format of:
(index, public address, private key)
will turn up in the blank area. However, there is no way around for you the download the csv outputs directly. The Print button might be okay, but it sadly fails to print addresses with index larger than 20. :(
Step 2: Download bitaddress.org code
Right click on the website, and choose Save as. Now you have the code script saved on your desktop. There should be two files included:
- bitaddress.org_files/ (folder)
Step 3: Start hacking!
Open the bitaddress.org.html file with whatever editor you love the most. A lovely notepad can work too!
Hint: We are modifying stuffs at the “Bulk Wallet” area, so we should start looking for items around Bulk. If you search for “bulktextarea” in bitaddress.org.html, you could easily find the functions that are handling bulk wallet (e.g. wallets.bulkwallet) at around line 10030.
Let’s add a new function below the “close” function, named “download”. This download function should contain codes about downloading the csv outputs. The function is implemented as the following:
This function has three major parts:
- csvContent captures the csv outputs in the “bulktextarea” and appends them to a csv file header.
- link creates an <a> with a downloadable file name as “BitcoinKeys.csv” and the content as encodedURI(csvContent), and appends itself to html.
- link clicks itself to trigger the download.
Make sure that the “download” function is placed correctly between the “close” function and the “buildCSV” function.
Step 4: Hook up the download button
Search for “buildCSV” to see in which part of the html calls this function. You will hit line 6708 at the following <span>:
<span><input type="button" id="bulkgenerate" value="Generate" onclick="ninja.wallets.bulkwallet.buildCSV(document.getElementById('bulklimit').value * 1, document.getElementById('bulkstartindex').value * 1, document.getElementById('bulkcompressed').checked, document.getElementById('bulkpassphrase').value);"> </span>
If you scroll down to line 6709, there is the Print button, which looks like this:
<span class="print"><input type="button" name="print" id="bulkprint" value="Print" onclick="window.print();"></span>
NOW it is your turn to add in a new “download” button with the following codes:
<span><input type="button" name="download" id="bulkdownload" value="Download" onclick="ninja.wallets.bulkwallet.download();"></span>
This function is nearly the same as the Print button. The slight differences are the name, id, value, and onclick function, which points to our newly created “download” function!
Hint: You may COMMENT OUT the Print button code, if you dislike it. :)
Step 5: Test it
Now save everything, and refresh the bitaddress.org.html file. You will see the Download button shining at the top right corner!! ❤
Go generate 3 wallets and click on the “Download” button to see how the magic happens!
In this super swift article, you have learned about the basic of Bitcoin address generation in bulk, and also the followings:
- Hack in and create a customized Download function
- Hook up the function with an additional Download button
The main idea of this tutorial is to show you that “You can always upgrade any tool that you feel not so handy!” Try to make a difference and contribute to the community anytime.
Hope you like the short tutorial. Feel free to let me know how you would like to work around bitaddress.org to create many other new features! :)
Code repository for lazy ppl (here)