Skip to content

Commit

Permalink
Move an expectation to the site where its invariant is enforced.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Dec 13, 2023
1 parent dfc2442 commit bd8f55d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,8 @@ impl SpendDescriptionInfo {

fn build<Pr: SpendProver>(
self,
anchor: Option<bls12_381::Scalar>,
anchor: bls12_381::Scalar,
) -> Result<SpendDescription<InProgress<Unproven, Unsigned>>, 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());

Expand Down Expand Up @@ -471,7 +469,12 @@ impl SaplingBuilder {
// Create the unauthorized Spend and Output descriptions.
let shielded_spends = spend_infos
.into_iter()
.map(|a| a.build::<SP>(self.anchor))
.map(|a| {
a.build::<SP>(
self.anchor
.expect("Sapling anchor must be set if Sapling spends are present."),
)
})
.collect::<Result<Vec<_>, _>>()?;
let shielded_outputs = output_infos
.into_iter()
Expand Down

0 comments on commit bd8f55d

Please sign in to comment.