From 17d152498d160a31ba0e1875c25f5b0f04d30e45 Mon Sep 17 00:00:00 2001 From: fedebuyito <126606287+fedebuyito@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:48:48 -0300 Subject: [PATCH 1/3] Update encode_qr.py Implementing "use_info.network" member provided on HDKey/CoinInfo classes (urtypes/crypto packages-libs folder) for testnet public key exporting option. --- src/seedsigner/models/encode_qr.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/seedsigner/models/encode_qr.py b/src/seedsigner/models/encode_qr.py index 65a8f5d1f..cd4daabe7 100644 --- a/src/seedsigner/models/encode_qr.py +++ b/src/seedsigner/models/encode_qr.py @@ -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 @@ -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 = CoinInfo(type=None, network=0 if self.network == "M" else 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 = [] From 405d0c8eac380711ab2260678456fb0542768a01 Mon Sep 17 00:00:00 2001 From: fedebuyito <126606287+fedebuyito@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:37:59 -0300 Subject: [PATCH 2/3] Update encode_qr.py Change in "self.use_info" assignation for to be "None" when mainnet. --- src/seedsigner/models/encode_qr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedsigner/models/encode_qr.py b/src/seedsigner/models/encode_qr.py index cd4daabe7..1b759ce5d 100644 --- a/src/seedsigner/models/encode_qr.py +++ b/src/seedsigner/models/encode_qr.py @@ -344,7 +344,7 @@ 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 = CoinInfo(type=None, network=0 if self.network == "M" else 1) + self.use_info = None if self.network == "M" else CoinInfo(type=None, network=1) self.ur_hdkey = HDKey({ 'key': self.xpub.key.serialize(), 'chain_code': self.xpub.chain_code, From 8d769c1ec954874e2bfa294f941e519d75933568 Mon Sep 17 00:00:00 2001 From: fedebuyito <126606287+fedebuyito@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:49:32 -0300 Subject: [PATCH 3/3] Update test_encodepsbtqr.py Updates first test (in test_ur_xpub_qr) to "MAINNET" and creates following for "TESTNET" --- tests/test_encodepsbtqr.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/test_encodepsbtqr.py b/tests/test_encodepsbtqr.py index 14feb1e03..2d864c12a 100644 --- a/tests/test_encodepsbtqr.py +++ b/tests/test_encodepsbtqr.py @@ -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"