Skip to content

Commit eca9469

Browse files
committed
Address review feedback
1 parent f526f69 commit eca9469

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/interpreter.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ bitflags::bitflags! {
2020
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2121
/// Script verification flags
2222
pub struct VerificationFlags: u32 {
23-
/// Evaluate P2SH subscripts (softfork safe, BIP16).
23+
/// Evaluate P2SH subscripts (softfork safe,
24+
/// [BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki).
2425
const P2SH = 1 << 0;
2526

2627
/// Passing a non-strict-DER signature or one with undefined hashtype to a checksig operation causes script failure.
@@ -29,19 +30,19 @@ bitflags::bitflags! {
2930
const StrictEnc = 1 << 1;
3031

3132
/// Passing a non-strict-DER signature or one with S > order/2 to a checksig operation causes script failure
32-
/// (softfork safe, BIP62 rule 5).
33+
/// (softfork safe, [BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 5).
3334
const LowS = 1 << 3;
3435

35-
/// verify dummy stack item consumed by CHECKMULTISIG is of zero-length (softfork safe, BIP62 rule 7).
36+
/// verify dummy stack item consumed by CHECKMULTISIG is of zero-length (softfork safe, [BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 7).
3637
const NullDummy = 1 << 4;
3738

38-
/// Using a non-push operator in the scriptSig causes script failure (softfork safe, BIP62 rule 2).
39+
/// Using a non-push operator in the scriptSig causes script failure (softfork safe, [BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 2).
3940
const SigPushOnly = 1 << 5;
4041

4142
/// Require minimal encodings for all push operations (OP_0... OP_16, OP_1NEGATE where possible, direct
4243
/// pushes up to 75 bytes, OP_PUSHDATA up to 255 bytes, OP_PUSHDATA2 for anything larger). Evaluating
43-
/// any other push causes the script to fail (BIP62 rule 3).
44-
/// In addition, whenever a stack element is interpreted as a number, it must be of minimal length (BIP62 rule 4).
44+
/// any other push causes the script to fail ([BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 3).
45+
/// In addition, whenever a stack element is interpreted as a number, it must be of minimal length ([BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 4).
4546
/// (softfork safe)
4647
const MinimalData = 1 << 6;
4748

@@ -58,13 +59,13 @@ bitflags::bitflags! {
5859
/// Require that only a single stack element remains after evaluation. This changes the success criterion from
5960
/// "At least one stack element must remain, and when interpreted as a boolean, it must be true" to
6061
/// "Exactly one stack element must remain, and when interpreted as a boolean, it must be true".
61-
/// (softfork safe, BIP62 rule 6)
62+
/// (softfork safe, [BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 6)
6263
/// Note: CLEANSTACK should never be used without P2SH.
6364
const CleanStack = 1 << 8;
6465

6566
/// Verify CHECKLOCKTIMEVERIFY
6667
///
67-
/// See BIP65 for details.
68+
/// See [BIP65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki) for details.
6869
const CHECKLOCKTIMEVERIFY = 1 << 9;
6970
}
7071
}

src/zcash_script.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ pub enum Error {
1818
Unknown(u32),
1919
}
2020

21+
/// All signature hashes are 32 bits, since they are necessarily produced by SHA256.
22+
pub const SIGHASH_SIZE: usize = 32;
23+
2124
/// A function which is called to obtain the sighash.
2225
/// - script_code: the scriptCode being validated. Note that this not always
2326
/// matches script_sig, i.e. for P2SH.
@@ -27,7 +30,7 @@ pub enum Error {
2730
/// reporting, but returning `None` indicates _some_ failure to produce the desired hash.
2831
///
2932
/// TODO: Can we get the “32” from somewhere rather than hardcoding it?
30-
pub type SighashCalculator<'a> = &'a dyn Fn(&[u8], HashType) -> Option<[u8; 32]>;
33+
pub type SighashCalculator<'a> = &'a dyn Fn(&[u8], HashType) -> Option<[u8; SIGHASH_SIZE]>;
3134

3235
/// The external API of zcash_script. This is defined to make it possible to compare the C++ and
3336
/// Rust implementations.
@@ -45,7 +48,6 @@ pub trait ZcashScript {
4548
/// - script_pub_key: the scriptPubKey of the output being spent.
4649
/// - script_sig: the scriptSig of the input being validated.
4750
/// - flags: the script verification flags to use.
48-
/// - err: if not NULL, err will contain an error/success code for the operation.
4951
///
5052
/// Note that script verification failure is indicated by `Err(Error::Ok)`.
5153
fn verify_callback(

0 commit comments

Comments
 (0)