Skip to content

Instantly share code, notes, and snippets.

@bitjson
Forked from jcramer/bst.schema.json
Created December 5, 2018 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitjson/3dbe0d06961439966d774103430a636f to your computer and use it in GitHub Desktop.
Save bitjson/3dbe0d06961439966d774103430a636f to your computer and use it in GitHub Desktop.
Bitcoin Script Template (BST) Schema
{
"description": "Definition file for Bitcoin Script Templates",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://p2sh.cash/bst.schema.json",
"title": "Bitcoin Script Template (BST) JSON Schema",
"type": "object",
"properties": {
"v":{
"description": "BST schema version",
"type": "integer",
"exclusiveMinimum": 0
},
"n":{
"description": "Name for this BST template",
"type": "string"
},
"d":{
"description": "Description for this BST template",
"type": "string"
},
"w":{
"description": "[NOT-YET-IMPLEMENTED]List of warnings and notes to the user",
"type": "array",
"items": { "type": "string" }
},
"x":{
"description": "User defined variables (not wallet friendly) which shall be selected or input by the user in the Template Options User Interface and may be referenced within the Locking and Unlocking Script Sections 'u' and 'l' for direct value replacement or controlling a 'repeat-*' type object.",
"type": "array",
"uniqueItems": true,
"items": {
"anyOf": [
{
"description": "opcode: A user defined opcode variable that will be selected via dropdown menu.",
"type": "object",
"properties": {
"n": { "description": "Name of a variable", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of variable", "type": "string", "oneOf": [ { "enum": [ "opcode" ] } ] },
"d": { "description": "Description of the opcode variable", "type": "string" },
"c": {
"description": "Constraints on an opcode type user specified variable",
"oneOf": [
{ "description": "[DEPRECIATED]Min/max range of valid opcodes", "type": "array", "items": { "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2},
{ "description": "[NOT-YET-IMPLEMENTED]Range of valid opcode (integer) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "[NOT-YET-IMPLEMENTED]Range of valid opcode (string) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "[NOT-YET-IMPLEMENTED]List of valid opcode (integer) values", "type": "object", "properties": { "l": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "[NOT-YET-IMPLEMENTED]List of valid opcode (string) values", "type": "object", "properties": { "l": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } }
]
}
},
"required": [ "n", "t" ]
},
{
"description": "pushdata[NOT-YET-IMPLEMENTED]: User defined pushdata variable that will be provided by the user via text input box.",
"type": "object",
"properties": {
"n": { "description": "Name of a variable", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of variable", "type": "string", "oneOf": [ { "enum": [ "pushdata[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the pushdata variable", "type": "string" },
"l": { "description": "Minimum and maximum byte length requirement [inclusive, exclusive]", "type": "array", "items": { "type": "integer" }, "minItems": 2, "maxItems": 2}
},
"required": [ "n", "t", "l" ]
},
{
"description": "time-*[NOT-YET-IMPLEMENTED]: A user defined time as a UNIX timestamp in seconds (absolute) or blocks (relative), encoded in little-endian format",
"type": "object",
"properties": {
"n": { "description": "Name of a variable", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of variable", "type": "string", "oneOf": [ { "enum": [ "time-absolute[NOT-YET-IMPLEMENTED]", "time-relative[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the time variable", "type": "string" }
}
},
{
"description": "numeric[NOT-YET-IMPLEMENTED]: A user defined signed numeric type value encoded in little-endian format",
"type": "object",
"properties": {
"n": { "description": "Name of a variable", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of variable", "type": "string", "oneOf": [ { "enum": [ "numeric[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the numeric variable", "type": "string" }
}
}
]
}
},
"u": {
"description": "Unlocking Script Templates (Note: There can be multiple unlocking script templates)",
"type":"array",
"uniqueItems": true,
"minItems": 0,
"items": {
"description": "The unlocking script template",
"type": "object",
"properties": {
"n": {
"description": "Name of the unlocking script",
"type": "string"
},
"s": {
"description": "Script template for unlocking part of script",
"type":"array",
"items": {
"anyOf": [
{
"description": "Integer is interpreted as an opcode value",
"type": "integer",
"oneOf": [ "valid_opcode_integers" ]
},
{
"description": "String starting with 'OP_' is replaced by interpreter with a opcode integer value",
"type": "string",
"oneOf": [ "valid_opcode_strings" ]
},
{
"description": "A string which shall match one of the user defined variables to be replaced by either the opcode or pushdata value selected by user in the template user options.",
"type": "string",
"pattern": "^(?!OP_)([A-Z0-9]+)$"
},
{
"description": "opcode[NOT-YET-IMPLEMENTED]: A single user selectable opcode input that will be selected via dropdown menu.",
"type": "object",
"properties": {
"n": { "description": "Name of a input", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of input", "type": "string", "oneOf": [ { "enum": [ "opcode[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the opcode input", "type": "string" },
"c": {
"description": "Constraints on an opcode type user specified input",
"oneOf": [
{ "description": "Range of valid opcode (integer) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "Range of valid opcode (string) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (integer) values", "type": "object", "properties": { "l": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (string) values", "type": "object", "properties": { "l": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } }
]
}
},
"required": [ "n", "t" ]
},
{
"description": "repeat-opcode[NOT-YET-IMPLEMENTED]: Repeating user selectable opcode input that will be selected via dropdown menu.",
"type": "object",
"properties": {
"n": { "description": "Name of a input", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of input", "type": "string", "oneOf": [ { "enum": [ "repeat-opcode[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the opcode input", "type": "string" },
"x": { "description": "User defined variable that is controlling the input repetitions.", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$"},
"c": {
"description": "Constraints on an opcode type user specified input",
"oneOf": [
{ "description": "Range of valid opcode (integer) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "Range of valid opcode (string) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (integer) values", "type": "object", "properties": { "l": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (string) values", "type": "object", "properties": { "l": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } }
]
}
},
"required": [ "n", "t", "x" ]
},
{
"description": "pushdata: A single user input field for arbitrary data to be pushed onto the stack (NOTE: 'i' section options provide to unlocking script to signal wallet friendliness)",
"type": "object",
"properties": {
"t": { "description": "Type of user input ('pushdata')", "type": "string", "oneOf": [ { "enum": [ "pushdata" ] } ] },
"i": { "description": "Intent and purpose for user input", "type": "string", "oneOf": [ { "enum": [ "sig-ec", "data-sig-ec", "utf8", "hash160", "sha256" ] } ] },
"n": { "description": "Display name of item to be created", "type": "string" },
"d": { "description": "Description of the user input field", "type": "string" },
"l": { "description": "Minimum and maximum byte length requirement [inclusive, exclusive]", "type": "array", "items": { "type": "integer" }, "minItems": 2, "maxItems": 2}
},
"required": [ "t", "n", "l" ]
},
{
"description": "repeat-pushdata: Repeated user input field for arbitrary data to be pushed onto the stack",
"type": "object",
"properties": {
"t": { "description": "Type of user input ('repeat-pushdata')", "type": "string", "oneOf": [ { "enum": [ "repeat-pushdata" ] } ] },
"i": { "description": "Intent and purpose for user input", "type": "string", "oneOf": [ { "enum": [ "sig-ec", "data-sig-ec", "utf8", "hash160", "sha256" ] } ] },
"n": { "description": "Display name of repeated item to be created (application should add '-#' after the name to provide user with a different name)", "type": "string" },
"d": { "description": "Description of the user input field", "type": "string" },
"x": { "description": "User defined variable that is controlling the input repetitions.", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$"},
"l": { "description": "Minimum and maximum byte length requirement [inclusive, exclusive]", "type": "array", "items": { "type": "integer" }, "minItems": 2, "maxItems": 2}
},
"required": [ "t", "n", "x", "l" ]
},
{
"description": "multiplex-opcode[NOT-YET-IMPLEMENTED]: Represents a range or list of opcode values that should be considered",
"type": "object",
"properties": {
"t": { "description": "Type of object ('multiplex-opcode')", "type": "string", "oneOf": [ { "enum": [ "multiplex-opcode[NOT-YET-IMPLEMENTED]" ] } ] },
"n": { "description": "Display name of repeated item to be created (application should add '-#' after the name to provide user with a different name)", "type": "string" },
"d": { "description": "Description of the user input field", "type": "string" },
"i": {
"description": "Items to be used in multiplex-opcode.",
"oneOf": [
{ "type": "object", "properties": {
"r": { "description": "Range of opcode (integer) values to consider [inclusive, exclusive]", "type": "array", "items": { "type":"integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "type": "object", "properties": {
"r": { "description": "Range of opcode (string) values to consider [inclusive, exclusive]", "type": "array", "items": { "type":"string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } },
{ "type": "object", "properties": {
"l": { "description": "List of opcode (integer) values to consider", "type": "array", "items": { "type": "integer", "oneOf": [ "valid_opcode_integers" ] } } } },
{ "type": "object", "properties": {
"l": { "description": "List of opcode (string) values to consider", "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] } } } }
]
}
},
"required": [ "t", "n" ]
}
]
}
}
},
"required": [ "n", "s" ]
}
},
"l":{
"description": "Locking script template",
"type":"array",
"minItems": 0,
"items": {
"anyOf": [
{
"description": "Integer hard-coded into a template is interpreted as an opcode value",
"type": "integer",
"oneOf": [ "valid_opcode_integers" ]
},
{
"description": "String hard-coded into a template starting with 'OP_' is replaced by interpreter with a opcode integer value",
"type": "string",
"oneOf": [ "valid_opcode_strings" ]
},
{
"description": "String hard-coded into a template should be a named user defined variable from the 'x' section above to be replaced after user makes selection in options menu.",
"type": "string",
"pattern": "^(?!OP_)([A-Z0-9]+)$"
},
{
"description": "script: A single instance of a pre-defined script hard-coded into the template as a string in hexadecimal format. Named user defined variables can be embedded using <XX> notation.",
"type": "object",
"properties": {
"t": { "description": "Type of input", "type": "string", "oneOf": [ { "enum": [ "script" ] } ]},
"d": { "description": "Description of the script", "type": "string" },
"s": { "description": "The pre-defined script which may include user defined variables using <XX> syntax", "type": "string", "pattern": "^[0-9a-fA-F]+$" }
},
"required": [ "t", "s" ]
},
{
"description": "repeat-script: Repeating pre-defined script stored in the template as a string in hexadecimal format. Named user defined variables can be embedded using <XX> notation.",
"type": "object",
"properties": {
"t": { "description": "Type of input", "type": "string", "oneOf": [ { "enum": [ "repeat-script" ] } ] },
"d": { "description": "Description of the script", "type": "string" },
"x": { "description": "User defined variable controlling the number of repetitions for this script.", "type": "string" },
"s": { "description": "The pre-defined script which may include user defined variables using <XX> syntax", "type": "string", "pattern": "^[0-9a-fA-F]+$" }
},
"required": [ "t", "s", "x" ]
},
{
"description": "opcode[NOT-YET-IMPLEMENTED]: A single user selectable opcode input that will be selected via dropdown menu.",
"type": "object",
"properties": {
"n": { "description": "Name of a input", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of input", "type": "string", "oneOf": [ { "enum": [ "opcode[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the opcode variable", "type": "string" },
"c": {
"description": "Constraints on an opcode type user specified variable",
"oneOf": [
{ "description": "Range of valid opcode (integer) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "Range of valid opcode (string) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (integer) values", "type": "object", "properties": { "l": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (string) values", "type": "object", "properties": { "l": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } }
]
}
},
"required": [ "n", "t" ]
},
{
"description": "repeat-opcode[NOT-YET-IMPLEMENTED]: Repeating user selectable opcode input that will be selected via dropdown menu.",
"type": "object",
"properties": {
"n": { "description": "Name of a input", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$" },
"t": { "description": "Type of input", "type": "string", "oneOf": [ { "enum": [ "repeat-opcode[NOT-YET-IMPLEMENTED]" ] } ] },
"d": { "description": "Description of the opcode input", "type": "string" },
"x": { "description": "User defined variable controlling the input repetitions.", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$"},
"c": {
"description": "Constraints on an opcode type user specified variable",
"oneOf": [
{ "description": "Range of valid opcode (integer) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "Range of valid opcode (string) values [inclusive, inclusive]", "type": "object", "properties": { "r": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (integer) values", "type": "object", "properties": { "l": { "type": "array", "items":{ "type": "integer", "oneOf": [ "valid_opcode_integers" ] }, "minItems": 2, "maxItems": 2 } } },
{ "description": "List of valid opcode (string) values", "type": "object", "properties": { "l": { "type": "array", "items": { "type": "string", "oneOf": [ "valid_opcode_strings" ] }, "minItems": 2, "maxItems": 2 } } }
]
}
},
"required": [ "n", "t", "x" ]
},
{
"description": "pushdata: A single user input field for arbitrary data to be pushed onto the stack. Special enum 'pubkey-ec' can be used to help a wallet determine which key to use for signing.",
"type": "object",
"properties": {
"t": { "description": "Type of user input ('pushdata')", "type": "string", "oneOf": [ { "enum": [ "pushdata" ] } ] },
"i": { "description": "Intent and purpose for user input", "type": "string", "oneOf": [ { "enum": [ "pubkey-ec", "hash160", "sha256", "utf8" ] } ] },
"n": { "description": "Display name of item to be created", "type": "string" },
"d": { "description": "Description of the user input field", "type": "string"},
"l": { "description": "Minimum and maximum byte length requirement [inclusive, exclusive]", "type": "array", "items": { "type": "integer" }, "minItems": 2, "maxItems": 2}
},
"required": [ "t", "n" ]
},
{
"description": "repeat-pushdata: Repeated user input field for arbitrary data to be pushed onto the stack",
"type": "object",
"properties": {
"t": { "description": "Type of user input ('repeat-pushdata')", "type": "string", "oneOf": [ { "enum": [ "repeat-pushdata" ] } ] },
"i": { "description": "Intent and purpose for user input", "type": "string", "oneOf": [ { "enum": [ "pubkey-ec", "hash160", "sha256", "utf8" ] } ] },
"n": { "description": "Display name of repeated item to be created (application should add '-#' after the name to provide user with a different name)", "type": "string" },
"d": { "description": "Description of the user input field", "type": "string" },
"x": { "description": "User defined variable controlling the input repetitions.", "type": "string", "pattern": "^(?!OP_)([A-Z0-9]+)$"},
"l": { "description": "Minimum and maximum byte length requirement [inclusive, exclusive]", "type": "array", "items": { "type": "integer" }, "minItems": 2, "maxItems": 2}
},
"required": [ "t", "n", "x" ]
}
]
}
}
},
"required": [ "v", "n", "l" ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment