Skip to content

Instantly share code, notes, and snippets.

@Rav3nPL
Created August 19, 2020 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rav3nPL/ea709183317bcdd764ff2a5268d63162 to your computer and use it in GitHub Desktop.
Save Rav3nPL/ea709183317bcdd764ff2a5268d63162 to your computer and use it in GitHub Desktop.
Want to create proper address for BURNING COINS? There is a tool for that purpose :)
#!/usr/bin/env python
# Special thanks to Gavin Andresen from bitcointalk.org
# in reference to: https://bitcointalk.org/index.php?topic=1026.0
# Edited By/Author Josh Lee PyTis.com,
#
# Cut and remake to troll address fixer by rav3n_pl :)
#
# WARNING!
#
# Any address "fixed" by this tool is valid, BUT you NOT have private key for it!
# It means, that if you send ANY coins to that address - that coins are LOST - BURNED!
#
# Use at OWN RISK and only FOR FUN.
#
# usage: just edit at end and run :)
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)
def b58decode(v, length):
""" decode v into a string of len bytes
"""
long_value = 0L
for (i, c) in enumerate(v[::-1]):
long_value += __b58chars.find(c) * (__b58base**i)
result = ''
while long_value >= 256:
div, mod = divmod(long_value, 256)
result = chr(mod) + result
long_value = div
result = chr(long_value) + result
nPad = 0
for c in v:
if c == __b58chars[0]:
nPad += 1
else:
break
result = chr(0)*nPad + result
if length is not None and len(result) != length:
if len(result) > length:
while len(result) < length: # too long, cut last char
return b58decode(v[:-1], length)
else:
while len(result) < length: # too short, copy last char
return b58decode(v+v[-1], length)
return result
def b58encode(v):
""" encode v, which is a string of bytes, to base58.
"""
long_value = 0L
for (i, c) in enumerate(v[::-1]):
long_value += (256**i) * ord(c)
result = ''
while long_value >= __b58base:
div, mod = divmod(long_value, __b58base)
result = __b58chars[mod] + result
long_value = div
result = __b58chars[long_value] + result
# Bitcoin does a little leading-zero-compression:
# leading 0-bytes in the input become leading-1s
nPad = 0
for c in v:
if c == '\0':
nPad += 1
else:
break
return (__b58chars[0]*nPad) + result
def fixIt(strAddress):
for (_, c) in enumerate(strAddress[::-1]):
if __b58chars.find(c) < 0: # we can not use non-base58 chars
print "Invalid char :(", c
return
from Crypto.Hash import SHA256
addr = b58decode(strAddress, 25)
if addr is None:
return None
checksum = addr[-4:]
vh160 = addr[:-4] # Version plus hash160 is what is checksummed
h3 = SHA256.new(SHA256.new(vh160).digest()).digest()
if h3[0:4] == checksum:
return b58encode(addr)
return b58encode(vh160+h3[0:4]) # just fix it :D
print fixIt("1noKYCnoAMLno")
print fixIt("1BSVtoSCAMjakZADEN")
print fixIt("3thisoneistooLongLongLongLongLongLongLongLong")
print fixIt("1thisOneIsspecIalbecauseItIsInvalId")
print fixIt("1Rav3nToBaaardzoZLYmoderatorj")
print fixIt("1VeryGoodTooLtoCreateBurningAddress")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment