Move an expectation to the site where its invariant is enforced.

This commit is contained in:
Kris Nuttycombe 2023-12-13 11:31:58 -07:00
parent dfc24428d0
commit bd8f55dbb5
1 changed files with 7 additions and 4 deletions

View File

@ -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());
@ -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()