You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of implicitly detecting whether or not an OP_VAULT/OP_UNVAULT
spend is a recovery spend by scanning outputs for matching
scriptPubKeys, explicitly indicate recoveries by requiring a witness
stack element that is either -1 in the case of no recovery OR
corresponds to an output index that is the recovery output.
Copy file name to clipboardExpand all lines: bip-vaults.mediawiki
+14-20Lines changed: 14 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -279,32 +279,26 @@ where
279
279
** If <code><recovery-params></code> is less than 32 bytes, script execution when spending this output MUST fail and terminate immediately.
280
280
** Because the recovery scriptPubKey is committed to with a hash, witness version upgradeability is preserved.
281
281
282
-
====Check for recovery====
282
+
====Witness stack====
283
283
284
284
After the witness program is parsed, it must be determined whether this input
285
-
is being spent towards a recovery. If an output in the spending transaction is
286
-
found whose scriptPubKey hashes to the recovery sPK hash (the
287
-
first component of <code><recovery-params></code>), the interpreter will
288
-
evaluate for recovery. Otherwise, the interpreter will evaluate assuming a withdrawal
289
-
is being triggered.
285
+
is being spent towards a recovery.
290
286
291
-
In pseudocode:
287
+
Witness stack shown top to bottom:
292
288
293
-
<sourcelang="python">
294
-
is_recovery = False
295
-
recovery_out: Optional[CTxOut] = None
296
-
297
-
for out in spending_tx.vout:
298
-
if tagged_hash("VaultRecoverySPK", out.scriptPubKey) == recovery_sPK_hash:
299
-
is_recovery = True
300
-
recovery_out = out
301
-
302
-
if is_recovery:
303
-
eval_for_recovery(recovery_out)
304
-
else:
305
-
eval_for_withdrawal_trigger()
289
+
<source>
290
+
<recovery-vout-idx>
291
+
[other potential witness stack items ...]
306
292
</source>
307
293
294
+
where
295
+
296
+
* <code><recovery-vout-idx></code> is an integer indicating which output, if any, is a recovery output.
297
+
** If this value cannot be decoded as a CScriptNum and cast to an integer, script execution MUST fail and terminate immediately.
298
+
** If this value is less than -1, script execution MUST fail and terminate immediately.
299
+
** If this value is greater than or equal to 0, this spend is a recovery transaction and this value denotes the recovery output that corresponds to this vault input.
300
+
* The parse of the other stack items depends on whether or not this is a recovery spend.
301
+
308
302
==== <code>OP_VAULT</code> evaluation for recovery spend ====
309
303
310
304
* If the recovery output does not have an <code>nValue</code> greater than this input's amount, the script MUST fail and terminate immediately.
0 commit comments