From bd8f55dbb5f619348adfdb4efd1a65ceb52fbe76 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 13 Dec 2023 11:31:58 -0700 Subject: [PATCH] Move an expectation to the site where its invariant is enforced. --- src/builder.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index be084af..ff209fe 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -93,10 +93,8 @@ impl SpendDescriptionInfo { fn build( self, - anchor: Option, + anchor: bls12_381::Scalar, ) -> Result>, Error> { - let anchor = anchor.expect("Sapling anchor must be set if Sapling spends are present."); - // Construct the value commitment. let cv = ValueCommitment::derive(self.note.value(), self.rcv.clone()); @@ -471,7 +469,12 @@ impl SaplingBuilder { // Create the unauthorized Spend and Output descriptions. let shielded_spends = spend_infos .into_iter() - .map(|a| a.build::(self.anchor)) + .map(|a| { + a.build::( + self.anchor + .expect("Sapling anchor must be set if Sapling spends are present."), + ) + }) .collect::, _>>()?; let shielded_outputs = output_infos .into_iter()