-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unpack command #433
Add unpack command #433
Conversation
@@ -90,7 +90,9 @@ impl<'a> Slatepacker<'a> { | |||
}; | |||
|
|||
slatepack.ver_check_warn(); | |||
slatepack.try_decrypt_payload(self.0.dec_key)?; | |||
if decrypt { | |||
slatepack.try_decrypt_payload(self.0.dec_key)?; |
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.
If I understand correctly when calling the unpack API with decrypt true and if the slatepack is not encrypted that will fail?
Why not:
- Try to decrypt by default without failing in a specific context.
- Do not return an error when unpacking with true and simply failover false 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.
Nevermind missed
pub fn try_decrypt_payload(&mut self, dec_key: Option<&edSecretKey>) -> Result<(), Error> {
if self.mode == 0 {
return Ok(());
}
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 testing it now. What is the rationale for having an additional decrypt arg instead of trying to decrypt it by default?
Tested and everything looks fine. |
Just that the logic flow was set up in most places to assume the decode function also handled decryption, was much easier to provide a flag to that function to allow it to handle the case where you just want the contents without decrypting than changing the flow everywhere. |
Great, thanks for testing! |
grin-wallet unpack
command, which unpacks a slatepack message, decrypts (if it's intended for this wallet), and displays the slate in JSON (if possible)