Return an error from NodeEntropy::from_bip39_mnemonic in bindings - #1058
Open
kaloudis wants to merge 1 commit into
Open
Return an error from NodeEntropy::from_bip39_mnemonic in bindings#1058kaloudis wants to merge 1 commit into
NodeEntropy::from_bip39_mnemonic in bindings#1058kaloudis wants to merge 1 commit into
Conversation
The uniffi-exposed `from_bip39_mnemonic` constructor was infallible and took the `Mnemonic` custom type, which parses the string during argument lifting. An invalid mnemonic would fail the lift and surface as an unexpected-error call status. The generated Swift wrapper for an infallible function wraps the call in `try!`, so passing an invalid mnemonic (e.g., a user typo during wallet restore) aborts the process with an uncatchable EXC_BREAKPOINT. Kotlin and Python raise their generic internal exceptions instead. Following the `from_seed_bytes` precedent, give the constructor a uniffi-specific signature that takes the mnemonic as a plain string and returns `Result<NodeEntropy, EntropyError>`, parsing inside the function and reporting failures via a new `EntropyError::InvalidMnemonic` variant. The non-uniffi Rust API is unchanged.
|
I've assigned @tnull as a reviewer! |
Collaborator
|
Ugh, sorry. We'll be working towards getting rid of all custom type to avoid these cases, seems we missed this so far :/ I think we should however do #1059, i.e., expose |
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.
The uniffi-exposed
from_bip39_mnemonicconstructor was infallible and took theMnemoniccustom type, which parses the string during argument lifting. An invalid mnemonic would fail the lift and surface as an unexpected-error call status. The generated Swift wrapper for an infallible function wraps the call intry!, so passing an invalid mnemonic (eg. a user typo during wallet restore) aborts the process with an uncatchable EXC_BREAKPOINT. Kotlin and Python raise their generic internal exceptions instead.Following the
from_seed_bytesprecedent, give the constructor a uniffi-specific signature that takes the mnemonic as a plain string and returnsResult<NodeEntropy, EntropyError>, parsing inside the function and reporting failures via a newEntropyError::InvalidMnemonicvariant. The non-uniffi Rust API is unchanged.Discovered in an ZEUS iOS user crash report.