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
Tt_pkcheck(key)key CHECKSIG-sig
Vv_pkkey CHECKSIGVERIFY-sig
Ff_pkkey CHECKSIGVERIFY 1-sig
Qq_pkkey-sig
Ee_pkkey CHECKSIG0sig
Ww_pkSWAP key CHECKSIG0sig

Multiple pubkey check

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Tt_multicheck(key1) + check(key2) + ... = kk key1 key2 ... n CHECKMULTISIG-0 sig1 sig2...
Vv_multik key1 key2 ... n CHECKMULTISIGVERIFY-0 sig1 sig2...
Ff_multik key1 key2 ... n CHECKMULTISIGVERIFY 1-0 sig1 sig2...
Ee_multik key1 key2 ... n CHECKMULTISIG0 0 0...0 sig1 sig2...
Ww_multiTAS k key1 key2 ... n CHECKMULTISIG FAS0 0 0...0 sig1 sig2...

Timelocks

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Tt_timecoin_age >= nn CHECKSEQUENCEVERIFY-empty
Vv_timen CHECKSEQUENCEVERIFY DROP-empty
Ff_timen CHECKSEQUENCEVERIFY 0NOTEQUAL-empty
Ee_timeDUP IF n CHECKSEQUENCEVERIFY DROP ENDIF01
Ww_timeSWAP DUP IF n CHECKSEQUENCEVERIFY01

Hash locks

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Tt_hashlen(x) = 32 and SHA256(x) = hashSIZE 32 EQUALVERIFY SHA256 hash EQUAL-x
Vv_hashSIZE 32 EQUALVERIFY SHA256 hash EQUALVERIFY-x
Ff_hashSIZE 32 EQUALVERIFY SHA256 hash EQUALVERIFY 1-x
Ww_hashSWAP SIZE 0NOTEQUAL IF SIZE 32 EQUALVERIFY SHA256 hash EQUALVERIFY 1 ENDIF0x

Conditional wraps

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Ee_lift_lif !c then A else 0IFNOT [F] ELSE 0 ENDIF10 sat(A)
Ww_lift_lTAS IFNOT [F] ELSE 0 ENDIF FAS10 sat(A)
Ee_lift_uif c then A else 0IF [F] ELSE 0 ENDIF01 sat(A)
Ww_lift_uTAS IF [F] ELSE 0 ENDIF FAS01 sat(A)

Conjunctions

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Tt_and_pA and B[V] [T]-sat(A) sat(B)
Vv_and_p[V] [V]-sat(A) sat(B)
Ff_and_p[V] [F]-sat(A) sat(B)
Ee_and_p[E] [W] BOOLANDnsat(A) nsat(B)sat(A) sat(B)
Ww_and_pTAS [E] [W] BOOLAND FASnsat(A) nsat(B)sat(A) sat(B)
Ee_and_cif !A then 0 else B[E] IFNOT ELSE 0 [F] ENDIFnsat(A)sat(A) sat(B)
Ww_and_cTAS [E] IFNOT ELSE 0 [F] ENDIF FASnsat(A)sat(A) sat(B)

Disjunctions

ConventionNode nameSemanticsScript representationNon-satisfactionA satisfactionB satisfaction
Tt_or_pA or B[E] [W] BOOLOR-sat(A) nsat(B)nsat(A) sat(B)
Ee_or_p[E] [W] BOOLORnsat(A) nsat(B)sat(A) nsat(B)nsat(A) sat(B)
Ww_or_pTAS [E] [W] BOOLOR FASnsat(A) nsat(B)sat(A) nsat(B)nsat(A) sat(B)
Tt_or_cif A then 1 else B[E] IFDUP NOTIF [T] ENDIF-sat(A)nsat(A) sat(B)
Ee_or_c[E] IFDUP NOTIF [E] ENDIFnsat(A) nsat(B)sat(A)nsat(A) sat(B)
Tt_or_v[E] NOTIF [V] ENDIF 1-sat(A)nsat(A) sat(B)
Vv_or_v[E] NOTIF [V] ENDIF-sat(A)nsat(A) sat(B)
Ff_or_v[E] NOTIF [V] ENDIF 1-sat(A)nsat(A) sat(B)
Tt_or_dif c then A else BIF [Q] ELSE [Q] ENDIF CHECKSIG-1 sat(A)0 sat(B)
Vv_or_dIF [Q] ELSE [Q] ENDIF CHECKSIGVERIFY-1 sat(A)0 sat(B)
Ff_or_dIF [Q] ELSE [Q] ENDIF CHECKSIGVERIFY 1-1 sat(A)0 sat(B)
Tt_or_sIF [T] ELSE [T] ENDIF-1 sat(A)0 sat(B)
Vv_or_sIF [V] ELSE [V] ENDIF-1 sat(A)0 sat(B)
Ff_or_sIF [F] ELSE [F] ENDIF-1 sat(A)0 sat(B)
Qq_or_sIF [Q] ELSE [Q] ENDIF-1 sat(A)0 sat(B)
Ee_or_sIF [F] ELSE [E] ENDIF0 nsat(B)1 sat(A)0 sat(B)
Ww_or_sTAS IF [F] ELSE [E] ENDIF FAS0 nsat(B)1 sat(A)0 sat(B)
Tt_or_aIF [V] ELSE [V] ENDIF 1-1 sat(A)0 sat(B)
Vv_or_aIF [T] ELSE [T] ENDIF VERIFY-1 sat(A)0 sat(B)
Ff_or_aIF [V] ELSE [V] ENDIF 1-1 sat(A)0 sat(B)
Ee_or_aif !c then A else BNOTIF [F] ELSE [E] ENDIF0 nsat(A)0 sat(A)1 sat(B)
Ww_or_aTAS NOTIF [F] ELSE [E] ENDIF FAS0 nsat(A)0 sat(A)1 sat(B)

Thresholds

ConventionNode nameSemanticsScript representationNon-satisfactionSatisfaction
Tt_thresA + B + ... = k[E] ([W] ADD)* k EQUAL-(sat|nsat)...
Vv_thres[E] ([W] ADD)* EQUALVERIFY-(sat|nsat)...
Ff_thres[E] ([W] ADD)* k EQUALVERIFY 1-(sat|nsat)...
Ee_thres[E] ([W] ADD)* k EQUALnsat...(sat|nsat)...
Ww_thresTAS [E] ([W] ADD)* k EQUAL FASnsat...(sat|nsat)...