|
| 1 | +bitflags::bitflags! { |
| 2 | + /// The different SigHash types, as defined in <https://zips.z.cash/zip-0143> |
| 3 | + /// |
| 4 | + /// TODO: This is currently defined as `i32` to match the `c_int` constants in this package, but |
| 5 | + /// should use librustzcash’s `u8` constants once we’ve removed the C++. |
| 6 | + #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 7 | + pub struct HashType: i32 { |
| 8 | + /// Sign all the outputs |
| 9 | + const All = 1; |
| 10 | + /// Sign none of the outputs - anyone can spend |
| 11 | + const None = 2; |
| 12 | + /// Sign one of the outputs - anyone can spend the rest |
| 13 | + const Single = 3; |
| 14 | + /// Anyone can add inputs to this transaction |
| 15 | + const AnyoneCanPay = 0x80; |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +bitflags::bitflags! { |
| 20 | + #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
| 21 | + /// Script verification flags |
| 22 | + pub struct VerificationFlags: u32 { |
| 23 | + /// Evaluate P2SH subscripts (softfork safe, |
| 24 | + /// [BIP16](https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki). |
| 25 | + const P2SH = 1 << 0; |
| 26 | + |
| 27 | + /// Passing a non-strict-DER signature or one with undefined hashtype to a checksig operation causes script failure. |
| 28 | + /// Evaluating a pubkey that is not (0x04 + 64 bytes) or (0x02 or 0x03 + 32 bytes) by checksig causes script failure. |
| 29 | + /// (softfork safe, but not used or intended as a consensus rule). |
| 30 | + const StrictEnc = 1 << 1; |
| 31 | + |
| 32 | + /// Passing a non-strict-DER signature or one with S > order/2 to a checksig operation causes script failure |
| 33 | + /// (softfork safe, [BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 5). |
| 34 | + const LowS = 1 << 3; |
| 35 | + |
| 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). |
| 37 | + const NullDummy = 1 << 4; |
| 38 | + |
| 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). |
| 40 | + const SigPushOnly = 1 << 5; |
| 41 | + |
| 42 | + /// Require minimal encodings for all push operations (OP_0... OP_16, OP_1NEGATE where possible, direct |
| 43 | + /// pushes up to 75 bytes, OP_PUSHDATA up to 255 bytes, OP_PUSHDATA2 for anything larger). Evaluating |
| 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). |
| 46 | + /// (softfork safe) |
| 47 | + const MinimalData = 1 << 6; |
| 48 | + |
| 49 | + /// Discourage use of NOPs reserved for upgrades (NOP1-10) |
| 50 | + /// |
| 51 | + /// Provided so that nodes can avoid accepting or mining transactions |
| 52 | + /// containing executed NOP's whose meaning may change after a soft-fork, |
| 53 | + /// thus rendering the script invalid; with this flag set executing |
| 54 | + /// discouraged NOPs fails the script. This verification flag will never be |
| 55 | + /// a mandatory flag applied to scripts in a block. NOPs that are not |
| 56 | + /// executed, e.g. within an unexecuted IF ENDIF block, are *not* rejected. |
| 57 | + const DiscourageUpgradableNOPs = 1 << 7; |
| 58 | + |
| 59 | + /// Require that only a single stack element remains after evaluation. This changes the success criterion from |
| 60 | + /// "At least one stack element must remain, and when interpreted as a boolean, it must be true" to |
| 61 | + /// "Exactly one stack element must remain, and when interpreted as a boolean, it must be true". |
| 62 | + /// (softfork safe, [BIP62](https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki) rule 6) |
| 63 | + /// Note: CLEANSTACK should never be used without P2SH. |
| 64 | + const CleanStack = 1 << 8; |
| 65 | + |
| 66 | + /// Verify CHECKLOCKTIMEVERIFY |
| 67 | + /// |
| 68 | + /// See [BIP65](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki) for details. |
| 69 | + const CHECKLOCKTIMEVERIFY = 1 << 9; |
| 70 | + } |
| 71 | +} |
0 commit comments