Bitcoin Burn Address Generator – How we created our token burn address in Python3

Why BTC burning addresses are needed

Nowadays, token burning is required by many blockchain applications. It happens by sending cryptocurrency units to a specific destination address where no private key exists. Therefore the balance can never be unlocked or withdrawn from this specific address.

The problem is if we just use a randomly generated Bitcoin address, like for example 1Eh49uHxd938GR2DXrR21JDxSG2UTf53Ds, we could say that no private key exists for this BTC address and customers would be safe to use it as a burning address. 

But with an address like this, customers never know it for sure. 

Therefore we need something more specific. 

Bitcoin addresses are encoded with Base58 encoding. Addresses consist of numerics, uppercase letters and lowercase letters, but without 0 (number zero), O (uppercase o), l (lowercase L) and I (uppercase i). All characters left are “123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz”This is done to avoid confusion while communicating BTC addresses. 

If we now create a human-readable address consisting of Base58 characters like “1THEWEATHERSGREAT….” We know that it would take billions of years to find a corresponding private key.

Note that the leading “1….” is required by a standard Bitcoin address on mainnet

Furthermore, we fill all other places with X’s after our message to make it unfeasible to ever discover a private key. 

For example, counterparty used the burning address “1CounterpartyXXXXXXXXXXXXXXXUWLpVr” for BTC burning and XCP issuance in 2014 and had been paying out between 1000 and 1500 XCP for each Bitcoin burned and because of the long pattern and human-readable code, we certainly know that no private key exists.

Why do we need a BTC burning address?

10XRecovery issues CO2 tokens to CO2 consumers like forest owners for each tonne they removed from the atmosphere

These tokens will get deleted by CO2 producers like farmers, gasoline car owners, etc.

To delete these CO2 tokens, people must send their tokens to our BTC burning address which is “1XRecoveryXXXXXXXXXXXXXXXXXXV47Rm7“.

Using this procedure, we can monitor all greenhouse gas tokens which have been burned.  

How did we create our CO2 token burning address for future use?

We created our burning address “1XRecoveryXXXXXXXXXXXXXXXXXXV47Rm7” with our custom python script that we want to share for other developers in similar situations.

You can see our full script at https://gist.github.com/dancodery/e26890a60cd676ca8ca3af8c247d0bb8

Let’s break it down. 

From lines 19 to 21, we check if the prefix only contains valid Base58 characters.

From lines 23 to 27, we make sure that the prefix is not longer than bitcoin addresses themselves and append X’s at the end of the address.

In line 32, we decode the address and cut the last 4 bytes, because we need them for our checksum.

In the next line, we calculate our checksum by hashing our decoded address two times sha256(sha256(decoded_address)) and only use the first 4 bytes

The last step is to encode our decoded address and checksum and to print it to our user. 

That’s it. The next question to ask is how to validate bitcoin addresses before sending funds to this address. We are going to show it in our next blog entry. You can also follow us on Twitter to stay up to date https://twitter.com/10xrecovery.

We hope you like this tutorial. If you do, you can leave a star on Github and check out our project 10XRecovery.

10XRecovery establishes a decentralized CO2 token which makes reforestation and owning trees more profitable and leaves price adjustments to the free market.