use alloc::string::String;
use alloc::vec::Vec;
use crate::{Pczt, common::Global};
#[cfg(feature = "orchard")]
mod orchard;
#[cfg(feature = "orchard")]
pub use orchard::OrchardError;
#[cfg(feature = "sapling")]
mod sapling;
#[cfg(feature = "sapling")]
pub use sapling::SaplingError;
#[cfg(feature = "transparent")]
mod transparent;
#[cfg(feature = "transparent")]
pub use transparent::TransparentError;
pub struct Updater {
pczt: Pczt,
}
impl Updater {
pub fn new(pczt: Pczt) -> Self {
Self { pczt }
}
pub fn update_global_with<F>(self, f: F) -> Self
where
F: FnOnce(GlobalUpdater<'_>),
{
let Pczt {
mut global,
transparent,
sapling,
orchard,
} = self.pczt;
f(GlobalUpdater(&mut global));
Self {
pczt: Pczt {
global,
transparent,
sapling,
orchard,
},
}
}
pub fn finish(self) -> Pczt {
self.pczt
}
}
pub struct GlobalUpdater<'a>(&'a mut Global);
impl GlobalUpdater<'_> {
pub fn set_proprietary(&mut self, key: String, value: Vec<u8>) {
self.0.proprietary.insert(key, value);
}
}