From 7e39082eeca4dbb9d6d4b4b13118f1c2beca3dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Habov=C5=A1tiak?= Date: Fri, 21 Oct 2022 12:05:25 +0200 Subject: [PATCH] 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 --- bitcoin/src/blockdata/script.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bitcoin/src/blockdata/script.rs b/bitcoin/src/blockdata/script.rs index 0b9af510..78aae321 100644 --- a/bitcoin/src/blockdata/script.rs +++ b/bitcoin/src/blockdata/script.rs @@ -987,9 +987,16 @@ impl Builder { self } - /// Adds an `OP_VERIFY` to the script, unless the most-recently-added - /// opcode has an alternate `VERIFY` form, in which case that opcode - /// is replaced e.g., `OP_CHECKSIG` will become `OP_CHECKSIGVERIFY`. + /// Adds an `OP_VERIFY` to the script or replaces the last opcode with VERIFY form. + /// + /// 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 { match self.1 { Some(opcodes::all::OP_EQUAL) => {