diff --git a/CHANGELOG.md b/CHANGELOG.md index 628a918..fb538ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `empty` method for the `Note` [#165] +- Add `From` trait implementation for `Error` [#166] + ## [0.27.0] - 2024-04-24 ### Added @@ -284,6 +289,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Canonical implementation shielded by feature. +[#166]: https://github.com/dusk-network/phoenix-core/issues/166 +[#165]: https://github.com/dusk-network/phoenix-core/issues/165 [#156]: https://github.com/dusk-network/phoenix-core/issues/156 [#155]: https://github.com/dusk-network/phoenix-core/issues/155 [#152]: https://github.com/dusk-network/phoenix-core/issues/152 diff --git a/src/error.rs b/src/error.rs index 557451e..ac65ff0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -54,6 +54,20 @@ impl From for Error { } } +impl From for Error { + fn from(err: DuskBytesError) -> Self { + match err { + DuskBytesError::InvalidData => Error::InvalidData, + DuskBytesError::BadLength { found, expected } => { + Error::BadLength(found, expected) + } + DuskBytesError::InvalidChar { ch, index } => { + Error::InvalidChar(ch, index) + } + } + } +} + impl From for DuskBytesError { fn from(err: Error) -> Self { match err { diff --git a/src/note.rs b/src/note.rs index b8ccb66..eafa7f8 100644 --- a/src/note.rs +++ b/src/note.rs @@ -192,6 +192,17 @@ impl Note { Self::new(rng, NoteType::Obfuscated, pk, value, blinding_factor) } + /// Creates a new empty [`Note`] + pub fn empty() -> Self { + Self { + note_type: NoteType::Transparent, + value_commitment: JubJubExtended::default(), + stealth_address: StealthAddress::default(), + pos: 0, + encryption: [0; ENCRYPTION_SIZE], + } + } + fn decrypt_data( &self, vk: &ViewKey,