use crate::orchard::{Action, Bundle};
impl super::Redactor {
pub fn redact_orchard_with<F>(mut self, f: F) -> Self
where
F: FnOnce(OrchardRedactor<'_>),
{
f(OrchardRedactor(&mut self.pczt.orchard));
self
}
}
pub struct OrchardRedactor<'a>(&'a mut Bundle);
impl OrchardRedactor<'_> {
pub fn redact_actions<F>(&mut self, f: F)
where
F: FnOnce(ActionRedactor<'_>),
{
f(ActionRedactor(Actions::All(&mut self.0.actions)));
}
pub fn redact_action<F>(&mut self, index: usize, f: F)
where
F: FnOnce(ActionRedactor<'_>),
{
if let Some(action) = self.0.actions.get_mut(index) {
f(ActionRedactor(Actions::One(action)));
}
}
pub fn clear_zkproof(&mut self) {
self.0.zkproof = None;
}
pub fn clear_bsk(&mut self) {
self.0.bsk = None;
}
}
pub struct ActionRedactor<'a>(Actions<'a>);
enum Actions<'a> {
All(&'a mut [Action]),
One(&'a mut Action),
}
impl ActionRedactor<'_> {
fn redact<F>(&mut self, f: F)
where
F: Fn(&mut Action),
{
match &mut self.0 {
Actions::All(actions) => {
for action in actions.iter_mut() {
f(action);
}
}
Actions::One(action) => {
f(action);
}
}
}
pub fn clear_spend_auth_sig(&mut self) {
self.redact(|action| {
action.spend.spend_auth_sig = None;
});
}
pub fn clear_spend_recipient(&mut self) {
self.redact(|action| {
action.spend.recipient = None;
});
}
pub fn clear_spend_value(&mut self) {
self.redact(|action| {
action.spend.value = None;
});
}
pub fn clear_spend_rho(&mut self) {
self.redact(|action| {
action.spend.rho = None;
});
}
pub fn clear_spend_rseed(&mut self) {
self.redact(|action| {
action.spend.rseed = None;
});
}
pub fn clear_spend_fvk(&mut self) {
self.redact(|action| {
action.spend.fvk = None;
});
}
pub fn clear_spend_witness(&mut self) {
self.redact(|action| {
action.spend.witness = None;
});
}
pub fn clear_spend_alpha(&mut self) {
self.redact(|action| {
action.spend.alpha = None;
});
}
pub fn clear_spend_zip32_derivation(&mut self) {
self.redact(|action| {
action.spend.zip32_derivation = None;
});
}
pub fn clear_spend_dummy_sk(&mut self) {
self.redact(|action| {
action.spend.dummy_sk = None;
});
}
pub fn redact_spend_proprietary(&mut self, key: &str) {
self.redact(|action| {
action.spend.proprietary.remove(key);
});
}
pub fn clear_spend_proprietary(&mut self) {
self.redact(|action| {
action.spend.proprietary.clear();
});
}
pub fn clear_output_recipient(&mut self) {
self.redact(|action| {
action.output.recipient = None;
});
}
pub fn clear_output_value(&mut self) {
self.redact(|action| {
action.output.value = None;
});
}
pub fn clear_output_rseed(&mut self) {
self.redact(|action| {
action.output.rseed = None;
});
}
pub fn clear_output_ock(&mut self) {
self.redact(|action| {
action.output.ock = None;
});
}
pub fn clear_output_zip32_derivation(&mut self) {
self.redact(|action| {
action.output.zip32_derivation = None;
});
}
pub fn clear_output_user_address(&mut self) {
self.redact(|spend| {
spend.output.user_address = None;
});
}
pub fn redact_output_proprietary(&mut self, key: &str) {
self.redact(|action| {
action.output.proprietary.remove(key);
});
}
pub fn clear_output_proprietary(&mut self) {
self.redact(|action| {
action.output.proprietary.clear();
});
}
pub fn clear_rcv(&mut self) {
self.redact(|action| {
action.rcv = None;
});
}
}