-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement Deserialize for PublicKey
, Algorithm
, UnlockConditions
, SiacoinOutputID
, SiacoinInputID
, SiacoinOutput
, SiacoinInput
, SiafundOutput
and SiafundInput
#32
Conversation
4784519
to
430df13
Compare
f29008a
to
0a692e8
Compare
|
||
/// An ed25519 public key that can be used to verify a signature | ||
#[derive(Debug, PartialEq, Clone, Copy)] | ||
pub struct PublicKey([u8; 32]); | ||
|
||
impl PublicKey { | ||
const PREFIX: &'static str = "ed25519:"; |
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'd like to draw some attention to this. Strictly speaking types.PublicKey
in core
adds this prefix when json marshaling. Unfortunately though, UnlockKey
with specifier ed25519 doesn't serialize the same as PublicKey
so UnlockKey
can't replace PublicKey
.
0a692e8
to
3fc34a5
Compare
3fc34a5
to
676cbe7
Compare
SiacoinOutput
and SiacoinInput
PublicKey
, UnlockKey
, Algorithm
, SiacoinOutput
and SiacoinInput
PublicKey
, UnlockKey
, Algorithm
, SiacoinOutput
and SiacoinInput
PublicKey
, Algorithm
, UnlockConditions
, SiacoinOutput
and SiacoinInput
b528873
to
3ca744a
Compare
PublicKey
, Algorithm
, UnlockConditions
, SiacoinOutput
and SiacoinInput
PublicKey
, Algorithm
, UnlockConditions
, SiacoinOutput
, SiacoinInput
, SiafundOutput
and SiafundInput
@@ -31,9 +31,9 @@ pub struct Hash256([u8; 32]); | |||
impl Serialize for Hash256 { | |||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> { | |||
if serializer.is_human_readable() { | |||
serializer.serialize_str(&self.to_string()) | |||
String::serialize(&self.to_string(), serializer) |
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.
FYI: these renames are for consistency rather than functionality. In theory &self.to_string().serialize(&serializer)
might also work but specifying the intended type first and then calling serialize
on it seemed like the most readable option to me.
PublicKey
, Algorithm
, UnlockConditions
, SiacoinOutput
, SiacoinInput
, SiafundOutput
and SiafundInput
PublicKey
, Algorithm
, UnlockConditions
, SiacoinOutputID
, SiacoinInputID
, SiacoinOutput
, SiacoinInput
, SiafundOutput
and SiafundInput
This includes a test that verifies both the binary and json encoding against actual output from
core
.