Improve doc of `Script::push_verify`

This rewords the doc to have a reasonable summary, adds a little background explaining the opcode behavior and the effect of the function when called multiple times.

Closes ##1154
This commit is contained in:
Martin Habovštiak 2022-10-21 12:05:25 +02:00 committed by Martin Habovstiak
parent fcf9bd07bc
commit 7e39082eec
1 changed files with 10 additions and 3 deletions

View File

@ -987,9 +987,16 @@ impl Builder {
self self
} }
/// Adds an `OP_VERIFY` to the script, unless the most-recently-added /// Adds an `OP_VERIFY` to the script or replaces the last opcode with VERIFY form.
/// opcode has an alternate `VERIFY` form, in which case that opcode ///
/// is replaced e.g., `OP_CHECKSIG` will become `OP_CHECKSIGVERIFY`. /// Some opcodes such as `OP_CHECKSIG` have a verify variant that works as if `VERIFY` was
/// in the script right after. To save space this function appends `VERIFY` only if
/// the most-recently-added opcode *does not* have an alternate `VERIFY` form. If it does
/// the last opcode is replaced. E.g., `OP_CHECKSIG` will become `OP_CHECKSIGVERIFY`.
///
/// Note that existing `OP_*VERIFY` opcodes do not lead to the instruction being ignored
/// because `OP_VERIFY` consumes an item from the stack so ignoring them would change the
/// semantics.
pub fn push_verify(mut self) -> Builder { pub fn push_verify(mut self) -> Builder {
match self.1 { match self.1 {
Some(opcodes::all::OP_EQUAL) => { Some(opcodes::all::OP_EQUAL) => {