[IOHKCRB-12] Improve error handling for wallet creation #542
[IOHKCRB-12] Improve error handling for wallet creation #542
Conversation
5e254f0
to
b461a72
Compare
b461a72
to
6ae5c81
Compare
Looking good, you might need to rebase your branch. The previous merge (#523 ) seems to have conflict with this one. |
Ok(e) => e, | ||
}; | ||
|
||
let wallet = bip44::Wallet::from_entropy(&entropy, &password, hdwallet::DerivationScheme::V2); | ||
|
||
let wallet_box = Box::new(wallet); | ||
Box::into_raw(wallet_box) | ||
unsafe { ptr::write(wallet_out, Box::into_raw(wallet_box)) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be a good idea to check the wallet_out pointer being non NULL and returning a friendly CardanoResult error if that's the case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see... The behavior is undefined in that case, wouldn't a panic with a message be better though? I think a null pointer here is most probably a bug in the caller?
Should I always check for null pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good. this is exactly the kind of error handling I was talking about.
Just need rebasing and then we can merge |
6ae5c81
to
753aff9
Compare
name: [IOHKCRB-12] Add test of transaction creation
Description
Error handling
cardano_wallet_new
return the created wallet as an out parameter and use the return value for the error code. This way it no longer returns a null pointer if the size of the entropy array is not valid.