Skip to content

Commit 6298c45

Browse files
Merge pull request #13 from rubixchain/arnab/mnemonic-fix
Fix: mnemonic assignment
2 parents c14c9c8 + 4a084b0 commit 6298c45

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

rubix/signer.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ def __init__(self, rubixClient: RubixClient, alias: str, mnemonic: str = "", con
4242
raise ValueError("RubixClient instance is required")
4343
self.__client: RubixClient = rubixClient
4444

45-
# Set or generate Mnemonic
46-
self.__mnemonic = ""
47-
if mnemonic == "":
48-
mnemonic_str = generate_bip39_mnemonic()
49-
if mnemonic_str is None or mnemonic_str.strip() == "":
50-
raise ValueError("Failed to generate mnemonic phrase.")
51-
self.__mnemonic = mnemonic_str
52-
else:
53-
self.__mnemonic = mnemonic
54-
5545
# Check if alias has been provided for their account
5646
if alias == "":
5747
raise ValueError("alias must be provided to initiate Signer")
@@ -63,6 +53,14 @@ def __init__(self, rubixClient: RubixClient, alias: str, mnemonic: str = "", con
6353
complete_key_path = os.path.join(complete_account_dir, alias)
6454
if not os.path.exists(complete_key_path):
6555
# Get the secp256k1 keypair from mnemonic
56+
if mnemonic == "":
57+
mnemonic_str = generate_bip39_mnemonic()
58+
if mnemonic_str is None or mnemonic_str.strip() == "":
59+
raise ValueError("Failed to generate mnemonic phrase.")
60+
self.__mnemonic = mnemonic_str
61+
else:
62+
self.__mnemonic = mnemonic
63+
6664
seed = get_seed_from_mnemonic(self.__mnemonic)
6765
self.__keypair = Secp256k1Keypair.from_mnemonic_seed(seed)
6866

@@ -93,6 +91,7 @@ def __init__(self, rubixClient: RubixClient, alias: str, mnemonic: str = "", con
9391
self.__keypair = rubixAcccount.keypair
9492
self.did = rubixAcccount.did
9593
self.quorum_type = 2
94+
self.__mnemonic = ""
9695

9796
def __quorum_type(self) -> int:
9897
"""Returns the quorum type for transaction"""

0 commit comments

Comments
 (0)