Skip to content

Commit f9442d5

Browse files
committed
Add paper wallet output to slip39.gui
1 parent ff93f40 commit f9442d5

File tree

10 files changed

+306
-67
lines changed

10 files changed

+306
-67
lines changed

images/1x1-ffffff3f.png

68 Bytes
Loading

images/1x1-ffffff54.png

68 Bytes
Loading

images/1x1-ffffffbf.png

68 Bytes
Loading

images/guilloche-center.png

560 KB
Loading

images/guilloche-center.svg

Lines changed: 101 additions & 0 deletions
Loading

slip39/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ def path_edit(
4343
edit: str,
4444
):
4545
"""Replace the current path w/ the new path, either entirely, or if only partially if a continuation
46-
'.../' followed by some new path segments is provided.
46+
'../' followed by some new path segments is provided.
4747
4848
"""
49-
if edit.startswith( '..' ):
49+
if edit.startswith( '.' ):
5050
new_segs = edit.lstrip( './' ).split( '/' )
5151
cur_segs = path.split( '/' )
5252
log.info( f"Using {edit} to replace last {len(new_segs)} of {path} with {'/'.join(new_segs)}" )

slip39/defaults.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
)
4242

4343
# Y X Margin
44-
CREDIT_CARD = (2+1/4, 3+3/8), 1/16
45-
INDEX_CARD = (3, 5), 1/8 # noqa: E241
4644
BUSINESS_CARD = (2, 3+1/2), 1/32 # noqa: E241
45+
CREDIT_CARD = (2+1/4, 3+3/8), 1/32
46+
INDEX_CARD = (3, 5), 1/16 # noqa: E241
4747
HALF_LETTER = (4+1/2, 8), 1/8 # noqa: E241 (actually, 2/letter, 3/legal)
4848
THIRD_LETTER = (10.5/4,8), 1/8 # noqa: E241 (actually, 3/letter, 4/legal)
4949

@@ -81,15 +81,13 @@
8181
59: '/|\\',
8282
}
8383

84-
85-
8684
BAUDRATE = 115200
8785

88-
FILENAME_KEYWORDS = [ 'name', 'date', 'time', 'crypto', 'path', 'address' ]
86+
FILENAME_KEYWORDS = ['name', 'date', 'time', 'crypto', 'path', 'address']
8987
FILENAME_FORMAT = "{name}-{date}+{time}-{crypto}-{address}.pdf"
9088

9189
# Default Crypto accounts (and optional paths) to generate
92-
CRYPTO_PATHS = [ 'ETH', 'BTC' ]
90+
CRYPTO_PATHS = ('ETH', 'BTC')
9391

9492
__o = "BB"
9593
__h = "DD"

slip39/gui/main.py

Lines changed: 171 additions & 50 deletions
Large diffs are not rendered by default.

slip39/layout.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,21 @@ def layout_card(
189189
card_mnemonics = card_bottom.add_region_proportional(
190190
Region( 'card-mnemonics', x1=0, y1=0, x2=13/16, y2=1 )
191191
)
192+
193+
# QR codes sqaare, and anchored to top and bottom of card.
192194
card_qr1 = card_bottom.add_region_proportional(
193195
Image( 'card-qr1', x1=13/16, y1=0, x2=1, y2=1/2 )
194196
)
195-
card_qr1.y2 = card_qr1.y1 + (card_qr1.x2 - card_qr1.x1) # make height same as width
197+
card_qr1_size = min( card_qr1.x2 - card_qr1.x1, card_qr1.y2 - card_qr1.y1 )
198+
card_qr1.x1 = card_qr1.x2 - card_qr1_size
199+
card_qr1.y2 = card_qr1.y1 + card_qr1_size
196200

197201
card_qr2 = card_bottom.add_region_proportional(
198202
Image( 'card-qr2', x1=13/16, y1=1/2, x2=1, y2=1 )
199203
)
200-
card_qr2.y1 = card_qr2.y2 - (card_qr2.x2 - card_qr2.x1) # make height same as width
204+
card_qr2_size = min( card_qr2.x2 - card_qr2.x1, card_qr2.y2 - card_qr2.y1 )
205+
card_qr2.x1 = card_qr2.x2 - card_qr2_size
206+
card_qr2.y1 = card_qr2.y2 - card_qr2_size
201207

202208
card_top.add_region_proportional(
203209
Text( 'card-title', x1=0, y1=0, x2=1, y2=40/100, bold=True )
@@ -266,6 +272,18 @@ def layout_wallet(
266272
Text( f'crypto-b{c_n}', x1=2/8, y1=-1/16, x2=7/8, y2=7/16, foreground=int( COLOR[c_n], 16 ), rotate=-45 )
267273
)
268274

275+
# # The background rosette and cryptocurrency symbol in the center
276+
# public_center_size = min( public.x2 - public.x1, public.y2 - public.y1 )
277+
# public.add_region(
278+
# Image(
279+
# 'center-bg',
280+
# x1 = public.x1 + ( public.x2 - public.x1 ) / 2 - public_center_size / 2,
281+
# y1 = public.y1 + ( public.y2 - public.y1 ) / 2 - public_center_size / 2,
282+
# x2 = public.x1 + ( public.x2 - public.x1 ) / 2 + public_center_size / 2,
283+
# y2 = public.y1 + ( public.y2 - public.y1 ) / 2 + public_center_size / 2,
284+
# )
285+
# )
286+
269287
# Public addresses are vertical on left- and right-hand of public Region. In order to fit the
270288
# longer ETH addresses into a space with a fixed-width font, we know that the ratio of the width
271289
# to the height has to be about 1/20. Rotation is downward around upper-left corner; so,
@@ -510,7 +528,7 @@ def output_pdf(
510528
version = None,
511529
error_correction = qrcode.constants.ERROR_CORRECT_M,
512530
box_size = 10,
513-
border = 0
531+
border = 1
514532
)
515533
qrc.add_data( acct.address )
516534
qrc.make( fit=True )
@@ -688,19 +706,21 @@ def write_pdfs(
688706
wall_tpl[f"crypto-b{c_n}"] = account.crypto
689707

690708
wall_tpl['name-label'] = "Wallet name:"
691-
wall_tpl['name-bg'] = os.path.join( images, '1x1-ffffff7f.png' )
709+
wall_tpl['name-bg'] = os.path.join( images, '1x1-ffffff54.png' )
692710
wall_tpl['name'] = name
693711

712+
# wall_tpl['center-bg'] = os.path.join( images, 'guilloche-center.png' )
713+
694714
public_qr = qrcode.QRCode(
695715
version = None,
696716
error_correction = qrcode.constants.ERROR_CORRECT_M,
697717
box_size = 10,
698718
border = 1,
699719
)
700720
public_qr.add_data( account.address )
701-
wall_tpl['address-l-bg'] = os.path.join( images, '1x1-ffffff7f.png' )
721+
wall_tpl['address-l-bg'] = os.path.join( images, '1x1-ffffff54.png' )
702722
wall_tpl['address-l'] = account.address
703-
wall_tpl['address-r-bg'] = os.path.join( images, '1x1-ffffff7f.png' )
723+
wall_tpl['address-r-bg'] = os.path.join( images, '1x1-ffffff54.png' )
704724
wall_tpl['address-r'] = account.address
705725

706726
wall_tpl['address-qr-t'] = 'PUBLIC ADDRESS'
@@ -716,14 +736,14 @@ def write_pdfs(
716736
)
717737
private_qr.add_data( private_enc )
718738

719-
wall_tpl['private-bg'] = os.path.join( images, '1x1-ffffff7f.png' )
739+
wall_tpl['private-bg'] = os.path.join( images, '1x1-ffffff54.png' )
720740

721741
# If not enough lines, will throw Exception, as it should! We don't want
722742
# to emit a Paper Wallet without the entire encrypted private key present.
723743
for ln,line in enumerate( chunker( private_enc, 40 )):
724744
wall_tpl[f"private-{ln}"] = line
725745
wall_tpl['private-hint-t'] = 'PASSPHRASE HINT:'
726-
wall_tpl['private-hint-bg'] = os.path.join( images, '1x1-ffffff7f.png' )
746+
wall_tpl['private-hint-bg'] = os.path.join( images, '1x1-ffffff54.png' )
727747
wall_tpl['private-hint'] = wallet_pwd_hint
728748
wall_tpl['private-qr-t'] = 'PRIVATE KEY'
729749
wall_tpl['private-qr'] = private_qr.make_image( back_color="transparent" ).get_image()

slip39/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ def chunker( sequence, size ):
6363
while sequence:
6464
yield sequence[:size]
6565
sequence = sequence[size:]
66-

0 commit comments

Comments
 (0)