Skip to content

Commit

Permalink
Merge pull request SeedSigner#610 from fedebuyito/resolves_issue_582
Browse files Browse the repository at this point in the history
Update encode_qr.py - Fixes SeedSigner#582
  • Loading branch information
newtonick authored Dec 24, 2024
2 parents c2ccb61 + 0496eea commit 9bfb7b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/seedsigner/models/encode_qr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from seedsigner.models.settings import SettingsConstants

from urtypes.crypto import PSBT as UR_PSBT
from urtypes.crypto import Account, HDKey, Output, Keypath, PathComponent, SCRIPT_EXPRESSION_TAG_MAP
from urtypes.crypto import Account, HDKey, Output, Keypath, PathComponent, SCRIPT_EXPRESSION_TAG_MAP, CoinInfo



Expand Down Expand Up @@ -344,11 +344,13 @@ def derivation_to_keypath(path: str) -> list:
return Keypath(arr, self.root.my_fingerprint, len(arr))

origin = derivation_to_keypath(self.derivation)
self.use_info = None if self.network == SettingsConstants.MAINNET else CoinInfo(type=None, network=1)

self.ur_hdkey = HDKey({ 'key': self.xpub.key.serialize(),
'chain_code': self.xpub.chain_code,
'origin': origin,
'parent_fingerprint': self.xpub.fingerprint})
'parent_fingerprint': self.xpub.fingerprint,
'use_info': self.use_info })

ur_outputs = []

Expand Down
20 changes: 17 additions & 3 deletions tests/test_encodepsbtqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,26 @@ def test_ur_xpub_qr():

e = UrXpubQrEncoder(
seed=Seed(mnemonic.split(), passphrase="pass"),
network=SettingsConstants.TESTNET,
network=SettingsConstants.MAINNET,
derivation="m/48h/1h/0h/2h",
qr_density=SettingsConstants.DENSITY__MEDIUM
)

assert e.next_part() == "UR:CRYPTO-ACCOUNT/1-4/LPADAACSKPCYMOMNLGRYHDCKOEADCYSSMECPONAOLYTAADMETAADDLOXAXHDCLAOKSRLNLKPUEGYATHPMNSNIYMUECBY"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/2-4/LPAOAACSKPCYMOMNLGRYHDCKKKGHZMLUZORPVDGUOTECSTTKTOLPCWPTNTLKZTTIZTBEAAHDCXVDTPMYRSTDMOPSCXFZ"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/3-4/LPAXAACSKPCYMOMNLGRYHDCKSPZSBZSPGERLGDATUYNLPYBTGYIYYKBTWTAOSWKSVTSGCHBYDKYAVDAMTAADMONDGDFD"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/4-4/LPAAAACSKPCYMOMNLGRYHDCKDYOTADLOCSDYYKADYKAEYKAOYKAOCYSSMECPONAXAAAYCYIOREKKJKAEAEAEWZWDMYON"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/4-4/LPAAAACSKPCYMOMNLGRYHDCKDYOTADLOCSDYYKADYKAEYKAOYKAOCYSSMECPONAXAAAYCYIOREKKJKAEAEAEWZWDMYON"


e = UrXpubQrEncoder(
seed=Seed(mnemonic.split(), passphrase="pass"),
network=SettingsConstants.TESTNET,
derivation="m/48h/1h/0h/2h",
qr_density=SettingsConstants.DENSITY__MEDIUM
)

assert e.next_part() == "UR:CRYPTO-ACCOUNT/1-5/LPADAHCSKECYRTPEDKMOHDCFOEADCYSSMECPONAOLYTAADMETAADDLONAXHDCLAOKSRLNLKPUENSAHBTHS"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/2-5/LPAOAHCSKECYRTPEDKMOHDCFGYATHPMNSNKKGHZMLUZORPVDGUOTECSTTKTOLPCWPTNTLKZTTIZTNDJSCF"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/3-5/LPAXAHCSKECYRTPEDKMOHDCFZTBEAAHDCXVDTPMYRSTDSPZSBZSPGERLGDATUYNLPYBTGYIYYKBDFGWPKE"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/4-5/LPAAAHCSKECYRTPEDKMOHDCFBTWTAOSWKSVTSGCHBYDKYAVDAHTAADEHOYAOADAMTAADDYOTADGYBKBWFE"
assert e.next_part() == "UR:CRYPTO-ACCOUNT/5-5/LPAHAHCSKECYRTPEDKMOHDCFLOCSDYYKADYKAEYKAOYKAOCYSSMECPONAXAAAYCYIOREKKJKAETODLFYWP"

0 comments on commit 9bfb7b2

Please sign in to comment.