Policy


Supported elements:
  • pk(HEX): Require public key HEX to sign
  • multi(NUM,HEX,HEX,...): Require that NUM out of the following HEX public keys sign
  • time(NUMBER): Require that a relative time NUMBER has passed since creating the output
  • hash(HEX): Require that the SHA256 preimage of HEX is revealed
  • and(EXPR,EXPR): Require that both subexpressions are satisfied
  • or(EXPR,EXPR): Require that one of the subexpressions is satisfied
  • aor(EXPR,EXPR): Same as above, but the first subexpression is more likely than the second
  • thres(NUM,EXPR,EXPR,...): Require that NUM out of the following subexpressions are satisfied
Shorthands:
  • C: A dummy compressed public key (usable as argument to pk or multi)
  • U: A dummy uncompressed public key (usable as argument to pk or multi)
  • H: A dummy hash (usable as argument to hash)


Spending cost

Hex script


Decoded script

Annotated policy


Calling conversions

ConventionShorthandBehavior under honest inputsBehavior under adverserial inputs
ToplevelTTakes its inputs from the top of the stack, which must satisfy the condition. Pushes a nonzero value on the stack.Aborts or pushes 0 on the stack.
VerifyVTakes its inputs from the top of the stack, which must satisfy the condition. Does not push anything onto the stack.Aborts
ForcedFTakes its inputs from the top of the stack, which must satisfy the condition. A 1 is pushed onto the stack.Aborts
QueueQTakes its inputs from the top of the stack, which must satisfy the condition. Pushes a public key on the stack with which a signature check still needs to happen.Aborts
ExpressionETakes its inputs from the top of the stack. If they satisfy the condition, a 1 is pushed onto the stack; otherwise a 0.Pushes 0 on the stack or aborts.
WrappedWTakes from the stack its inputs + element X at the top. If the inputs satisfy the condition, [1 X] or [X 1] is pushed. If not, [0 X] or [X 0] is pushed.Pushes [0 X] or [X 0] onto the stack, or aborts.

Legend

Pubkey check

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
T, Epkcheck(key)key CHECKSIG0sig
Vpk_vkey CHECKSIGVERIFY-sig
Qpk_kkey-sig
Wpk_wSWAP key CHECKSIG0sig

Multiple pubkey check

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
T, Emulticheck(key1) + check(key2) + ... = kk key1 key2 ... n CHECKMULTISIG0 0 0...0 sig1 sig2...
Vmulti_vk key1 key2 ... n CHECKMULTISIGVERIFY-0 sig1 sig2...

Timelocks

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Ttime_tcoin_age >= nn CHECKSEQUENCEVERIFY-empty
Vtime_vn CHECKSEQUENCEVERIFY DROP-empty
Ftime_fn CHECKSEQUENCEVERIFY 0NOTEQUAL-empty
EtimeDUP IF n CHECKSEQUENCEVERIFY DROP ENDIF01
Wtime_wSWAP DUP IF n CHECKSEQUENCEVERIFY DROP ENDIF01

Hash locks

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Thash_tlen(x) = 32 and SHA256(x) = hashSIZE 32 EQUALVERIFY SHA256 hash EQUAL-x
Vhash_vSIZE 32 EQUALVERIFY SHA256 hash EQUALVERIFY-x
Whash_wSWAP SIZE 0NOTEQUAL IF SIZE 32 EQUALVERIFY SHA256 hash EQUALVERIFY 1 ENDIF0x

Wrappers

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Elikelyif !c then A else 0NOTIF [F] ELSE 0 ENDIF10 sat(A)
Eunlikelyif c then A else 0IF [F] ELSE 0 ENDIF01 sat(A)
WwrapATOALTSTACK [E] FROMALTSTACKnsat(A)sat(A)
FtrueA[V] 1-sat(A)

Conjunctions

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Tand_catA and B[V] [T]-sat(A) sat(B)
V[V] [V]-sat(A) sat(B)
F[V] [F]-sat(A) sat(B)
Q[V] [Q]-sat(A) sat(B)
Eand_bool[E] [W] BOOLANDnsat(A) nsat(B)sat(A) sat(B)
Eand_cascif !A then 0 else B[E] NOTIF 0 ELSE [F] ENDIFnsat(A)sat(A) sat(B)

Disjunctions

ConventionNode nameSemanticsScript representationNon-satisfactionA satisfactionB satisfaction
T, Eor_boolA or B[E] [W] BOOLORnsat(A) nsat(B)sat(A) nsat(B)nsat(A) sat(B)
Tor_cascif A then A else B[E] IFDUP NOTIF [T] ENDIF-sat(A)nsat(A) sat(B)
E[E] IFDUP NOTIF [E] ENDIFnsat(A) nsat(B)sat(A)nsat(A) sat(B)
Vor_contif !A then B[E] NOTIF [V] ENDIF-sat(A)nsat(A) sat(B)
Tor_keyif c then A else BIF [Q] ELSE [Q] ENDIF CHECKSIG-1 sat(A)0 sat(B)
Vor_key_vIF [Q] ELSE [Q] ENDIF CHECKSIGVERIFY-1 sat(A)0 sat(B)
Tor_ifIF [T] ELSE [T] ENDIF-1 sat(A)0 sat(B)
VIF [V] ELSE [V] ENDIF-1 sat(A)0 sat(B)
FIF [F] ELSE [F] ENDIF-1 sat(A)0 sat(B)
QIF [Q] ELSE [Q] ENDIF-1 sat(A)0 sat(B)
EIF [F] ELSE [E] ENDIF0 nsat(B)1 sat(A)0 sat(B)
Vor_if_vIF [T] ELSE [T] ENDIF VERIFY-1 sat(A)0 sat(B)
Eor_notifif !c then A else BNOTIF [F] ELSE [E] ENDIF0 nsat(A)0 sat(A)1 sat(B)

Thresholds

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
T, EthresA + B + ... = k[E] ([W] ADD)* k EQUALnsat...(sat|nsat)...
Vthres_v[E] ([W] ADD)* k EQUALVERIFY-(sat|nsat)...