Skip to content

Commit bfc8841

Browse files
committed
Include first 3 SLIP-39 mnemonics in group recovery instructions
1 parent 480a59c commit bfc8841

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

slip39/layout/pdf.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,6 @@ def layout_pdf(
181181
return LayoutPDF( comps_pp, orientation, page_xy, pdf, comp_dim )
182182

183183

184-
def output_pdf( *args, **kwds ):
185-
warnings.warn(
186-
"output_pdf() is deprecated; use produce_pdf instead.",
187-
PendingDeprecationWarning,
188-
)
189-
_,pdf,accounts = produce_pdf( *args, **kwds )
190-
return pdf,accounts
191-
192-
193184
def produce_pdf(
194185
name: str,
195186
group_threshold: int, # SLIP-39 Group Threshold required
@@ -253,7 +244,7 @@ def produce_pdf(
253244
group_reqs = list(
254245
f"{g_nam}({g_of}/{len(g_mns)})" if g_of != len(g_mns) else f"{g_nam}({g_of})"
255246
for g_nam,(g_of,g_mns) in groups.items() )
256-
requires = f"Recover w/ {group_threshold} of {len(group_reqs)} groups {', '.join(group_reqs[:4])}{'...' if len(group_reqs) > 4 else ''}"
247+
requires = f"Recover {'(via BIP-39) ' if using_bip39 else ''}w/ {group_threshold} of {len(group_reqs)}: {', '.join(group_reqs[:4])}{'...' if len(group_reqs) > 4 else ''}"
257248

258249
# Convert all of the first group's account(s) to an address QR code
259250
assert accounts and accounts[0], \
@@ -285,7 +276,7 @@ def produce_pdf(
285276
cover = Region(
286277
'cover', 0, 0, cvw / MM_IN, cvh / MM_IN
287278
).add_region_relative(
288-
Box( 'cover-interior', x1=+1/2, y1=+1/2, x2=-1/2, y2=-1/2 )
279+
Region( 'cover-interior', x1=+1/4, y1=+1/4, x2=-1/4, y2=-1/4 )
289280
)
290281
cover.add_region_proportional(
291282
Image( 'cover-image', x1=1/4, x2=3/4, y1=1/4, y2=3/4, priority=-3 )
@@ -296,7 +287,7 @@ def produce_pdf(
296287
Text( 'cover-text', y2=1/45, font='mono', multiline=True ) # 1st line
297288
)
298289
cover.add_region_proportional(
299-
Region( 'cover-rhs', x1=3/5, y1=1/5 ) # On right, below full-width header
290+
Region( 'cover-rhs', x1=55/100, y1=1/5 ) # On right, below full-width header
300291
).add_region_proportional(
301292
Text( 'cover-sent', y2=1/25, font='mono', multiline=True ) # 1st line
302293
)
@@ -314,8 +305,9 @@ def produce_pdf(
314305
g_nam_max = max( map( len, groups.keys() ))
315306
for g_nam,(g_of,g_mns) in groups.items():
316307
slip39_mnems.extend( g_mns )
317-
slip39_group.append( f"{g_nam:{g_nam_max}}: {g_of} of {len(g_mns)} to recover" )
318-
slip39_group.extend( f" {i+1:2}: ____________________" for i in range( len( g_mns )))
308+
#slip39_group.append( f"{g_nam:{g_nam_max}}: {g_of} of {len(g_mns)} to recover" )
309+
slip39_group.append(f"{g_nam+':':8}{g_of}/{len(g_mns)}: {' '.join(g_mns[0].split()[:3])}")
310+
slip39_group.extend( f"{i+1:2}: ______________________" for i in range( len( g_mns )))
319311
if using_bip39:
320312
# Add the BIP-39 Mnemonics to the cover_text, by recovering the master_secret from the
321313
# SLIP-39 Mnemonics.
@@ -487,7 +479,7 @@ def write_pdfs(
487479
extendable = extendable,
488480
identifier = identifier,
489481
)
490-
for name in names or [ "SLIP39" ]
482+
for name in names or [ "" ]
491483
}
492484

493485
if text and using_bip39:
@@ -517,7 +509,7 @@ def write_pdfs(
517509
g_nam_max = max( map( len, details.groups.keys() ))
518510
for g_name,(g_of,g_mnems) in details.groups.items():
519511
for i,mnem in enumerate( g_mnems ):
520-
print( f"{name} {g_name:{g_nam_max}} {i+1}: {mnem}" )
512+
print( f"{name or 'SLIP39'} {g_name:{g_nam_max}} {i+1}: {mnem}" )
521513
# Get the correct cover page format (if any), according to the details.using_bip39
522514
if cover_page:
523515
cover_text = open(os.path.join(os.path.dirname(__file__), 'COVER.txt'), encoding='UTF-8').read()
@@ -545,7 +537,7 @@ def write_pdfs(
545537
now = datetime.now()
546538

547539
pdf_name = ( filename or FILENAME_FORMAT ).format(
548-
name = name,
540+
name = name or "SLIP39",
549541
date = datetime.strftime( now, '%Y-%m-%d' ),
550542
time = datetime.strftime( now, '%H.%M.%S'),
551543
crypto = accounts[0][0].crypto,

0 commit comments

Comments
 (0)