Skip to content

Commit

Permalink
Clarify panic conditions in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
upbqdn committed Jan 30, 2025
1 parent 2e32fd6 commit 3b25023
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions zebra-chain/src/primitives/zcash_primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ impl<'a> PrecomputedTxData<'a> {
/// # Panics
///
/// - If `tx` can't be converted to its `librustzcash` equivalent.
/// - If `nu` doesn't contain a consensus branch id convertible to its `librustzcash`
/// equivalent.
///
/// # Consensus
///
Expand Down
4 changes: 4 additions & 0 deletions zebra-chain/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ impl Transaction {
/// - if called on a v1 or v2 transaction
/// - if the input index points to a transparent::Input::CoinBase
/// - if the input index is out of bounds for self.inputs()
/// - if the tx contains `nConsensusBranchId` field and `nu` doesn't match it
/// - if the tx is not convertible to its `librustzcash` equivalent
/// - if `nu` doesn't contain a consensus branch id convertible to its `librustzcash`
/// equivalent
pub fn sighash(
&self,
nu: NetworkUpgrade,
Expand Down
8 changes: 8 additions & 0 deletions zebra-chain/src/transaction/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ pub struct SigHasher<'a> {

impl<'a> SigHasher<'a> {
/// Create a new SigHasher for the given transaction.
///
/// # Panics
///
/// - If `trans` can't be converted to its `librustzcash` equivalent. This could happen, for
/// example, if `trans` contains the `nConsensusBranchId` field, and `nu` doesn't match it.
/// More details in [`PrecomputedTxData::new`].
/// - If `nu` doesn't contain a consensus branch id convertible to its `librustzcash`
/// equivalent.
pub fn new(
trans: &'a Transaction,
nu: NetworkUpgrade,
Expand Down

0 comments on commit 3b25023

Please sign in to comment.