Skip to content

Commit 676e342

Browse files
committed
Handle double-sided for paper wallets
1 parent 4fdb89f commit 676e342

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

SLIP-39-macOS.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ app = BUNDLE(
4444
exe,
4545
name='SLIP-39.app',
4646
icon='images/SLIP-39.icns',
47-
version='11.0.2',
47+
version='11.1.1',
4848
info_plist={
49-
'CFBundleVersion':'11.0.2',
49+
'CFBundleVersion':'11.1.1',
5050
'CFBundlePackageType':'APPL',
5151
'LSApplicationCategoryType':'public.app-category.utilities',
5252
'LSMinimumSystemVersion':'10.15.0',

slip39/layout/pdf.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,12 +522,12 @@ def write_pdfs(
522522
# Unless no card_format (False) or paper wallet password specified, produce a PDF containing
523523
# the SLIP-39 mnemonic recovery cards; remember the deduced (<pdf_paper>,<pdf_orient>). If
524524
# we're producing paper wallets, always force portrait orientation for the cards, to match.
525-
if card_format is not False or wallet_pwd:
525+
if card_format is not False or wallet_pwd is not None:
526526
(pdf_paper,pdf_orient),pdf,_ = produce_pdf(
527527
*details,
528528
card_format = card_format or CARD,
529529
paper_format = paper_format or PAPER,
530-
orientations = ('portrait', ) if wallet_pwd else None,
530+
orientations = ('portrait', ) if wallet_pwd is not None else None,
531531
cover_text = cover_text,
532532
watermark = watermark,
533533
double_sided = double_sided,
@@ -546,7 +546,7 @@ def write_pdfs(
546546
if not pdf_name.lower().endswith( '.pdf' ):
547547
pdf_name += '.pdf'
548548

549-
if wallet_pwd:
549+
if wallet_pwd is not None:
550550
# Deduce the paper wallet size and create a template. All layouts are in specified in
551551
# inches; template dimensions are in mm.
552552
try:
@@ -580,6 +580,8 @@ def write_pdfs(
580580
p,(offsetx,offsety) = page_xy( wall_n )
581581
if p != page_n:
582582
pdf.add_page( orientation='P', format=wallet_paper )
583+
if double_sided is None or double_sided:
584+
pdf.add_page( orientation='P', format=wallet_paper )
583585
page_n = p
584586
try:
585587
private_enc = account.encrypted( wallet_pwd )
@@ -654,7 +656,7 @@ def write_pdfs(
654656

655657
wall_tpl.render( offsetx=offsetx, offsety=offsety )
656658

657-
if json_pwd:
659+
if json_pwd is not None:
658660
# If -j|--json supplied, also emit the encrypted JSON wallet. This may be a *different*
659661
# password than the SLIP-39 master secret encryption passphrase. It will be required to
660662
# decrypt and use the saved JSON wallet file, eg. to load a software Ethereum wallet.
@@ -690,7 +692,8 @@ def write_pdfs(
690692
log.warning( f"Wrote JSON {name or 'SLIP39'}'s encrypted ETH wallet {eth.address} derived at {eth.path} to: {json_name}" )
691693

692694
if pdf:
693-
# Add the encrypted JSON account recovery to the PDF also, if generated.
695+
# Add the encrypted JSON account recovery to the PDF also, if generated. Last
696+
# page, so no need to handle double_sided for subsequent output.
694697
pdf.add_page()
695698
margin_mm = PAGE_MARGIN * MM_IN
696699
pdf.set_margin( 1.0 * MM_IN )

slip39/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def main( argv=None ):
7777
help="Save an encrypted JSON wallet for each Ethereum address w/ this password, '-' reads it from stdin (default: None)" )
7878
ap.add_argument( '-w', '--wallet',
7979
default=None,
80-
help="Produce paper wallets in output PDF; each wallet private key is encrypted this password" )
80+
help="Produce paper wallets in output PDF; each wallet private key is encrypted this password (use --wallet=\"\" for empty password)" )
8181
ap.add_argument( '--wallet-hint',
8282
default=None,
8383
help="Paper wallets password hint" )
@@ -86,7 +86,7 @@ def main( argv=None ):
8686
help=f"Paper wallet size; {', '.join(WALLET_SIZES.keys())} or '(<h>,<w>),<margin>' (default: {WALLET})" )
8787
ap.add_argument( '-s', '--secret',
8888
default=None,
89-
help="Use the supplied 128-, 256- or 512-bit hex value as the secret seed; '-' reads it from stdin (eg. output from slip39.recover)" )
89+
help="Use the supplied BIP-39 Mnemonic or 128-, 256- or 512-bit hex value as the secret seed; '-' reads it from stdin (eg. output from slip39.recover)" )
9090
ap.add_argument( '--bits',
9191
default=None, # Do not enforce default of 128-bit seeds
9292
help=f"Ensure that the seed is of the specified bit length; {', '.join( map( str, BITS ))} supported." )
@@ -196,7 +196,7 @@ def main( argv=None ):
196196
wallet_format = args.wallet_format
197197

198198
json_pwd = args.json
199-
if json_pwd:
199+
if json_pwd is not None:
200200
if json_pwd == '-':
201201
json_pwd = input_secure( 'Ethereum JSON wallet file password: ', secret=True )
202202
else:

slip39/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = ( 11, 1, 0 )
1+
__version_info__ = ( 11, 1, 1 )
22
__version__ = '.'.join( map( str, __version_info__ ))

0 commit comments

Comments
 (0)