Skip to content

Instantly share code, notes, and snippets.

@odudex
Last active March 27, 2023 12:00
Show Gist options
  • Save odudex/a29de0c91c4010a6b4c565d6f29fa0c6 to your computer and use it in GitHub Desktop.
Save odudex/a29de0c91c4010a6b4c565d6f29fa0c6 to your computer and use it in GitHub Desktop.
Uses Embit to convert BIP39 seed words to Tiny Seed format.
"""Uses Embit to convert BIP39 seed words to Tiny Seed format.
Install Embit:
pip install embit
Exemple: python tiny_seed.py rail price fiction dice orphan have allow spatial share country mixed gasp
"""
import sys
from embit.wordlists.bip39 import WORDLIST
TOP = """ .############################################.
.################################################.
.######## ###.
##.`#´.## 2 1 ###
######### 0 0 5 2 1 ###
## ## 4 2 1 5 2 6 3 1 ###
######### 8 4 2 6 8 4 2 6 8 4 2 1 ###"""
BOTTOM = """.###. .###.
.################################################.
.#############################################."""
def _draw_punched(words, page):
"""Draws punched bits for import and export Tinyseed UI"""
for x in range(12):
index = page * 12 + x
if isinstance(words[0], str):
word_list_index = WORDLIST.index(words[index]) + 1
else:
word_list_index = words[page * 12 + x]
print("### ------------------------------------- ### ")
line_string = "### "
if index + 1 < 10:
line_string += " "
line_string += str(index + 1)
for y in range(12):
if (word_list_index >> (11 - y)) & 1:
line_string += "|⚪️"
else:
line_string += "| "
print(line_string + "| ###")
print("### ------------------------------------- ### ")
if page == 1:
print("### X| | | | | | | | | | | | | ###")
print("### ------------------------------------- ###")
else:
print("### ###")
if len(sys.argv) in (13, 25):
pages = 1 if len(sys.argv) == 13 else 2
mnemonic = " ".join(sys.argv[1:])
mnemonic = mnemonic.split()
for page in range(pages):
print(TOP)
_draw_punched(mnemonic, page)
print(BOTTOM)
print("\n")
else:
print("Inform a 12 or 24 BIP39 words seed")
print(str(len(sys.argv) - 1) + " words were given")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment