Skip to content

Print first 3 words of each group on cover page #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions slip39/layout/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def produce_pdf(
group_reqs = list(
f"{g_nam}({g_of}/{len(g_mns)})" if g_of != len(g_mns) else f"{g_nam}({g_of})"
for g_nam,(g_of,g_mns) in groups.items() )
requires = f"Recover w/ {group_threshold} of {len(group_reqs)} groups {', '.join(group_reqs[:4])}{'...' if len(group_reqs)>4 else ''}"
requires = f"Need {group_threshold} of {len(group_reqs)} groups"

# Convert all of the first group's account(s) to an address QR code
assert accounts and accounts[0], \
Expand Down Expand Up @@ -247,16 +247,11 @@ def produce_pdf(
).add_region_relative(
Box( 'cover-interior', x1=+1/2, y1=+1/2, x2=-1/2, y2=-1/2 )
)
cover.add_region_proportional(
Image( 'cover-image', x1=1/4, x2=3/4, y1=1/4, y2=3/4, priority=-3 )
).square().add_region(
Image( 'cover-fade', priority=-2 )
)
cover.add_region_proportional(
Text( 'cover-text', y2=1/45, font='mono', multiline=True ) # 1st line
)
cover.add_region_proportional(
Region( 'cover-rhs', x1=3/5, y1=1/5 ) # On right, below full-width header
Region( 'cover-rhs', x1=0.58, y1=1/5 ) # On right, below full-width header
).add_region_proportional(
Text( 'cover-sent', y2=1/25, font='mono', multiline=True ) # 1st line
)
Expand All @@ -266,16 +261,15 @@ def produce_pdf(
log.debug( f"Cover elements: {json.dumps( cover_elements, indent=4)}" )
tpl_cover = fpdf.FlexTemplate( pdf, cover_elements )
images = os.path.dirname( __file__ )
tpl_cover['cover-image'] = os.path.join( images, 'SLIP-39.png' )
tpl_cover['cover-fade'] = os.path.join( images, '1x1-ffffffbf.png' )

slip39_mnems = []
slip39_group = []
slip39_group = [requires]
g_nam_max = max( map( len, groups.keys() ))
for g_nam,(g_of,g_mns) in groups.items():
slip39_mnems.extend( g_mns )
slip39_group.append( f"{g_nam:{g_nam_max}}: {g_of} of {len(g_mns)} to recover" )
slip39_group.extend( f" {i+1:2}: ____________________" for i in range( len( g_mns )))
slip39_group.append( "" )
slip39_group.append(f"{g_nam} ({g_of}/{len(g_mns)}): {' '.join(g_mns[0].split()[:3])}")
slip39_group.extend(f"{i+1:2} __________________________" for i in range(len(g_mns)))
if using_bip39:
# Add the BIP-39 Mnemonics to the cover_text, by recovering the master_secret from the
# SLIP-39 Mnemonics.
Expand All @@ -293,8 +287,7 @@ def produce_pdf(
cover_text += "\n"

tpl_cover['cover-text'] = cover_text
cover_sent = "SLIP-39 Mnemonic Card Recipients:\n\n"
cover_sent += "\n".join( slip39_group )
cover_sent = "\n".join( slip39_group )
tpl_cover['cover-sent'] = cover_sent

pdf.add_page()
Expand Down