pub struct Note { /* private fields */ }Expand description
A Note is a text and signatures.
Implementations§
Source§impl Note
impl Note
Sourcepub fn new(text: &[u8], existing_sigs: &[Signature]) -> Result<Self, NoteError>
pub fn new(text: &[u8], existing_sigs: &[Signature]) -> Result<Self, NoteError>
Returns a new note, ensuring that the text is well-formed, and appending the provided signatures.
§Errors
Returns a NoteError::MalformedNote if the text is larger than
we’re willing to parse, cannot be decoded as UTF-8, or contains
any non-newline ASCII control characters.
Sourcepub fn from_bytes(msg: &[u8]) -> Result<Self, NoteError>
pub fn from_bytes(msg: &[u8]) -> Result<Self, NoteError>
Parses the message msg into a note, returning a NoteError if any of the text or signatures are malformed.
§Errors
Returns a NoteError::MalformedNote if the message is larger than
we’re willing to parse, cannot be decoded as UTF-8, contains
any non-newline ASCII control characters, or is otherwise invalid.
Sourcepub fn verify(
&self,
known: &impl Verifiers,
) -> Result<(Vec<Signature>, Vec<Signature>), NoteError>
pub fn verify( &self, known: &impl Verifiers, ) -> Result<(Vec<Signature>, Vec<Signature>), NoteError>
Checks signatures on the note for those from known verifiers.
For each signature in the message, Note::verify calls known.verifier to find a verifier.
If known.verifier returns a verifier and the verifier accepts the signature,
Note::verify includes the signature in the returned list of verified signatures.
If known.verifier returns a VerificationError::UnknownKey,
Note::verify includes the signature in the returned list of unverified signatures.
§Errors
If known.verifier returns a verifier but the verifier rejects the signature,
Note::verify returns a NoteError::InvalidSignature.
If known.verifier returns any other error, Note::verify returns that error.
If no known verifier has signed an otherwise valid note,
Note::verify returns an NoteError::UnverifiedNote.
Sourcepub fn add_sigs(&mut self, signers: &[&dyn Signer]) -> Result<(), NoteError>
pub fn add_sigs(&mut self, signers: &[&dyn Signer]) -> Result<(), NoteError>
Signs the note with the given signers. The new signatures from signers are listed in the encoded message after the existing signatures already present in n.sigs. If any signer uses the same key as an existing signature, the existing signature is removed.
§Errors
Returns an error if any signers have invalid names. Names must be non-empty and not have any Unicode spaces or pluses.