Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion slip39/layout/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,10 @@ def write_pdfs(
wall_tpl[f"crypto-f{c_n}"] = account.crypto
wall_tpl[f"crypto-b{c_n}"] = account.crypto

wall_tpl['center'] = os.path.join( images, account.crypto + '.png' )
# Not every cryptocurrency has a logo; if not, leave the center of the wallet blank
logo = os.path.join( images, account.crypto + '.png' )
if os.path.exists( logo ):
wall_tpl['center'] = logo

wall_tpl['name-label'] = "Wallet:"
wall_tpl['name-bg'] = os.path.join( images, '1x1-ffffff54.png' )
Expand Down
18 changes: 17 additions & 1 deletion slip39/output_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytest
import qrcode

from pytest import approx
from fpdf import FPDF, FlexTemplate

from .layout import Region, Text, Image, Box, Coordinate
from .layout import Region, Text, Image, Box, Coordinate, write_pdfs
from .defaults import MM_IN


Expand Down Expand Up @@ -73,3 +74,18 @@ def test_Region():
tpl.render( offsetx = card_size.x * MM_IN, offsety = card_size.y * MM_IN )

#pdf.output( "test.pdf" ) # To view results in test.pdf, uncomment


def test_wallet_without_logo( tmp_path ):
"""A cryptocurrency without a logo image (eg. Dash) still gets a Paper Wallet, w/ a blank center."""
pytest.importorskip( "Crypto.Protocol.KDF" ) # BIP-38 encrypted Paper Wallets require scrypt
results = write_pdfs(
names = [ "Test" ],
master_secret = bytes.fromhex( "ff" * 16 ),
cryptocurrency = [ "DASH" ],
filepath = str( tmp_path ),
filename = "wallet-dash",
wallet_pwd = "password",
)
assert list( results ) == [ "wallet-dash.pdf" ]
assert ( tmp_path / "wallet-dash.pdf" ).stat().st_size > 0
Loading