Thread mnemonic password through wallet SDK#132
Merged
Conversation
The engine requires the BIP39 mnemonic password on load (loadExisting verifies it reproduces the wallet ID and throws otherwise), but the wallet SDK load path never carried it. Password-protected wallets created via createRailgunWalletFromMnemonicWithPassword could therefore never be reloaded after unload/restart. Thread an optional mnemonicPassword through loadExistingWallet and the public loadWalletByID, forwarding it to engine.loadExistingWallet. Fix the round-trip test to supply the password on reload, and add a negative test asserting a missing/wrong password is rejected.
Remove the ambiguous createRailgunWalletFromMnemonicWithPassword and add an optional trailing mnemonicPassword to createRailgunWallet instead, so there is a single create entrypoint. Omitted/empty preserves the legacy no-password wallet ID; the internal createWallet still routes empty to engine.createWalletFromMnemonic. Update tests to the consolidated API.
The engine added a password param to Mnemonic.to0xPrivateKey, but the exported mnemonicTo0xPKey util still derived without it, silently returning the wrong 0x private key for password-protected wallets. Forward an optional mnemonicPassword; omitting/empty preserves the legacy no-password key. Add a test covering both cases.
mesquka
previously approved these changes
Jun 18, 2026
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for creating and using wallets derived from a mnemonic with a password, and updates the transaction and wallet services to consistently accept and propagate an optional
mnemonicPasswordparameter. This allows for enhanced wallet security and flexibility in transaction generation and gas estimation flows. Additionally, a new helper function is introduced for wallet creation with a mnemonic password, along with corresponding tests.Wallet creation and management:
createRailgunWalletFromMnemonicWithPasswordinwallets.tsto support creating wallets using a mnemonic and password, including error handling.createWallet) to handle optionalmnemonicPassword, selecting the appropriate engine method based on its presence.wallets.test.ts.createRailgunWalletfunction to pass an empty string formnemonicPasswordto maintain compatibility.Transaction generation and proof flows:
mnemonicPasswordas an optional parameter to all transaction generation, proof, and gas estimation functions intx-generator.ts,tx-cross-contract-calls.ts,tx-proof-transfer.ts,tx-proof-unshield.ts,tx-transfer.ts, andtx-unshield.ts, ensuring it is properly threaded through all relevant calls. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]mnemonicPasswordparameter where needed. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]These updates ensure that all wallet and transaction operations can securely utilize a mnemonic password when required, improving overall security and flexibility.