post quote reposts impl

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-09-17 12:20:29 -04:00
parent 8e32f757f0
commit de9e0e4ca1
12 changed files with 275 additions and 20 deletions

View File

@@ -6,6 +6,8 @@ use std::hash::{Hash, Hasher};
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct NoteId([u8; 32]);
static HRP_NOTE: nostr::bech32::Hrp = nostr::bech32::Hrp::parse_unchecked("note");
impl NoteId {
pub fn new(bytes: [u8; 32]) -> Self {
NoteId(bytes)
@@ -23,6 +25,10 @@ impl NoteId {
let evid = NoteId(hex::decode(hex_str)?.as_slice().try_into().unwrap());
Ok(evid)
}
pub fn to_bech(&self) -> Option<String> {
nostr::bech32::encode::<nostr::bech32::Bech32>(HRP_NOTE, &self.0).ok()
}
}
/// Event is the struct used to represent a Nostr event