Skip to content

Commit 4aae726

Browse files
jamesobsanket1729
andcommitted
fixup! fix off-by-one and revault-idx malleability
Co-authored-by: sanket1729 <[email protected]>
1 parent e2ff23b commit 4aae726

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bip-0345.mediawiki

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,9 @@ where
246246
* <code><n-pushes></code> is an up to 4-byte <code>CScriptNum</code>-encoded number indicating how many leaf-update script items should be popped off the stack. <ref>'''Why only prepending with data pushes?''' Prepending the <code>leaf-update-script-body</code> with opcodes opens up the door to prepending OP_SUCCESSX opcodes, to name a single issue only, side-stepping the validation that was meant to be run by the committed script.</ref>
247247
** If this value does not decode to a valid CScriptNum, script execution when spending this output MUST fail and terminate immediately.
248248
** If this value is less than 0, script execution when spending this output MUST fail and terminate immediately.
249-
** If fewer than <code><n-pushes> + 2</code> items are on the stack, script execution when spending this output MUST fail and terminate immediately.
249+
** If there are fewer than 3 items following the <code><n-pushes></code> items on the stack, script execution when spending this output MUST fail and terminate immediately. In other words, after popping <code><leaf-update-script-body></code>, there must be at least <code>3 + <n-pushes></code> items remaining on the stack.
250250
251251
* The following <code><n-pushes></code> stack items are popped off the stack and prefixed as minimally-encoded push-data arguments to the <code><leaf-update-script-body></code> to construct the expected tapleaf replacement script.
252-
** If there are fewer than <code><n-pushes> + 2</code> items on the stack, script execution when spending this output MUST fail and terminate immediately.
253252
254253
* <code><trigger-vout-idx></code> is an up to 4-byte CScriptNum-encoded number indicating the index of the output which, in conjunction with an optional revault output, carries forward the value of this input, and has an identical taptree aside from the currently executing leaf.
255254
** If this value does not decode to a valid CScriptNum, script execution when spending this output MUST fail and terminate immediately.
@@ -258,6 +257,7 @@ where
258257
* <code><revault-vout-idx></code> is an up to 4-byte CScriptNum-encoded number optionally indicating the index of an output which, in conjunction with the trigger output, carries forward the value of this input, and has an identical scriptPubKey to the current input.
259258
** If this value does not decode to a valid CScriptNum, script execution when spending this output MUST fail and terminate immediately.
260259
** If this value is greater than or equal to the number of outputs, script execution when spending this output MUST fail and terminate immediately.
260+
** If this value is negative and not equal to -1, script execution when spending this output MUST fail and terminate immediately.<ref>'''Why is -1 the only allowable negative value for revault-vout-idx?''' A negative revault index indicates that no revault output exists; if this value were allowed to be any negative number, the witness could be malleated (and bloated) while a transaction is waiting for confirmation.</ref>
261261
262262
* <code><revault-amount></code> is an up to 7-byte CScriptNum-encoded number indicating the number of satoshis being revaulted.
263263
** If this value does not decode to a valid CScriptNum, script execution when spending this output MUST fail and terminate immediately.

0 commit comments

Comments
 (0)