From 3b2efb67d8288a2c8360b31da9f548e2fa2092b4 Mon Sep 17 00:00:00 2001 From: moana Date: Tue, 30 Apr 2024 16:23:25 +0100 Subject: [PATCH] Add `empty` method for the `Note` Resolves #156 --- CHANGELOG.md | 5 +++++ src/note.rs | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 628a918..de6acc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `empty` method for the `Note` [#165] + ## [0.27.0] - 2024-04-24 ### Added @@ -284,6 +288,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Canonical implementation shielded by feature. +[#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/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,