mirror of https://github.com/zcash/orchard.git
Add value_balance to orchard builder
This commit is contained in:
parent
3faab98e9e
commit
c88fdf1c59
|
@ -221,6 +221,7 @@ pub struct Builder {
|
||||||
recipients: Vec<RecipientInfo>,
|
recipients: Vec<RecipientInfo>,
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
anchor: Anchor,
|
anchor: Anchor,
|
||||||
|
value_balance: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Builder {
|
impl Builder {
|
||||||
|
@ -231,9 +232,15 @@ impl Builder {
|
||||||
recipients: vec![],
|
recipients: vec![],
|
||||||
flags,
|
flags,
|
||||||
anchor,
|
anchor,
|
||||||
|
value_balance: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the net value represented by the spends and outputs added to this builder.
|
||||||
|
pub fn value_balance(&self) -> i64 {
|
||||||
|
self.value_balance
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds a note to be spent in this transaction.
|
/// Adds a note to be spent in this transaction.
|
||||||
///
|
///
|
||||||
/// - `note` is a spendable note, obtained by trial-decrypting an [`Action`] using the
|
/// - `note` is a spendable note, obtained by trial-decrypting an [`Action`] using the
|
||||||
|
@ -277,6 +284,8 @@ impl Builder {
|
||||||
merkle_path,
|
merkle_path,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.value_balance += note.value().inner() as i64;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,6 +308,8 @@ impl Builder {
|
||||||
memo,
|
memo,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.value_balance -= value.inner() as i64;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue