Sapling builder can store network params.
This commit is contained in:
parent
4878b5b19b
commit
b487a7f820
|
@ -162,13 +162,13 @@ impl<'a, P: consensus::Parameters, R: RngCore> Builder<'a, P, R> {
|
|||
/// OF BUILDERS WITH NON-CryptoRng RNGs
|
||||
fn new_internal(params: P, target_height: BlockHeight, rng: R) -> Builder<'a, P, R> {
|
||||
Builder {
|
||||
params,
|
||||
params: params.clone(),
|
||||
rng,
|
||||
target_height,
|
||||
expiry_height: target_height + DEFAULT_TX_EXPIRY_DELTA,
|
||||
fee: DEFAULT_FEE,
|
||||
transparent_builder: TransparentBuilder::empty(),
|
||||
sapling_builder: SaplingBuilder::empty(target_height),
|
||||
sapling_builder: SaplingBuilder::empty(params, target_height),
|
||||
change_address: None,
|
||||
#[cfg(feature = "zfuture")]
|
||||
tze_builder: TzeBuilder::empty(),
|
||||
|
@ -203,7 +203,7 @@ impl<'a, P: consensus::Parameters, R: RngCore> Builder<'a, P, R> {
|
|||
memo: Option<MemoBytes>,
|
||||
) -> Result<(), Error> {
|
||||
self.sapling_builder
|
||||
.add_output(&mut self.rng, &self.params, ovk, to, value, memo)
|
||||
.add_output(&mut self.rng, ovk, to, value, memo)
|
||||
.map_err(Error::SaplingBuild)
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,6 @@ impl<'a, P: consensus::Parameters, R: RngCore> Builder<'a, P, R> {
|
|||
let (spend_descs, output_descs, tx_metadata) = self
|
||||
.sapling_builder
|
||||
.build(
|
||||
&self.params,
|
||||
prover,
|
||||
&mut ctx,
|
||||
&mut self.rng,
|
||||
|
@ -541,7 +540,7 @@ mod tests {
|
|||
expiry_height: sapling_activation_height + DEFAULT_TX_EXPIRY_DELTA,
|
||||
fee: Amount::zero(),
|
||||
transparent_builder: TransparentBuilder::empty(),
|
||||
sapling_builder: SaplingBuilder::empty(sapling_activation_height),
|
||||
sapling_builder: SaplingBuilder::empty(TEST_NETWORK, sapling_activation_height),
|
||||
change_address: None,
|
||||
#[cfg(feature = "zfuture")]
|
||||
tze_builder: TzeBuilder::empty(),
|
||||
|
|
|
@ -205,6 +205,7 @@ impl SaplingMetadata {
|
|||
}
|
||||
|
||||
pub struct SaplingBuilder<P: consensus::Parameters> {
|
||||
params: P,
|
||||
anchor: Option<bls12_381::Scalar>,
|
||||
target_height: BlockHeight,
|
||||
value_balance: Amount,
|
||||
|
@ -213,8 +214,9 @@ pub struct SaplingBuilder<P: consensus::Parameters> {
|
|||
}
|
||||
|
||||
impl<P: consensus::Parameters> SaplingBuilder<P> {
|
||||
pub fn empty(target_height: BlockHeight) -> Self {
|
||||
pub fn empty(params: P, target_height: BlockHeight) -> Self {
|
||||
SaplingBuilder {
|
||||
params,
|
||||
anchor: None,
|
||||
target_height,
|
||||
value_balance: Amount::zero(),
|
||||
|
@ -270,14 +272,13 @@ impl<P: consensus::Parameters> SaplingBuilder<P> {
|
|||
pub fn add_output<R: RngCore>(
|
||||
&mut self,
|
||||
mut rng: R,
|
||||
params: &P,
|
||||
ovk: Option<OutgoingViewingKey>,
|
||||
to: PaymentAddress,
|
||||
value: Amount,
|
||||
memo: Option<MemoBytes>,
|
||||
) -> Result<(), Error> {
|
||||
let output = SaplingOutput::new_internal(
|
||||
params,
|
||||
&self.params,
|
||||
self.target_height,
|
||||
&mut rng,
|
||||
ovk,
|
||||
|
@ -304,7 +305,6 @@ impl<P: consensus::Parameters> SaplingBuilder<P> {
|
|||
|
||||
pub fn build<Pr: TxProver, R: RngCore>(
|
||||
&self,
|
||||
params: &P,
|
||||
prover: &Pr,
|
||||
ctx: &mut Pr::SaplingProvingContext,
|
||||
mut rng: R,
|
||||
|
@ -440,7 +440,7 @@ impl<P: consensus::Parameters> SaplingBuilder<P> {
|
|||
}
|
||||
};
|
||||
|
||||
let rseed = generate_random_rseed_internal(params, target_height, &mut rng);
|
||||
let rseed = generate_random_rseed_internal(&self.params, target_height, &mut rng);
|
||||
|
||||
(
|
||||
payment_address,
|
||||
|
|
Loading…
Reference in New Issue