Ventimore Ltd | |||||||||
HOME DOCS | |||||||||
ScriptsTransaction scripts are binary, low level objects designed to be executed efficiently. They consist of a sequence of opcodes and data. Transaction scripts are generally generated from script language. I.e. More information can be found here. Data FormatThe script interpreter (which executes the binary script) assumes that the next byte in a binary script is an opcode (not data) unless one of the OP_PUSHDATA opcodes is encountered. Data is stored in one of the following format
The first format (no OP_PUSHDATAX) can only be used if the data length specifier is less than 75. The 2-byte and 4-byte length specifiers should be CScriptNum objects. The data contains no type information. For example, the data may actually represent a string, but the interpreter will happily treat the data as a number and attempt to mulitply it with a number if asked to (and probably producing an error). The standard Bitcoin script language (asm) allows data to be represented as
These formats have a number of idiosyncracies. 1. The hex 0xAABBCC does mean the hex number 0xAABBCC (whose binary implementation is machine dependent), rather it represents the byte sequence 0xAA, 0xBB, 0xCC. 2. It is common practice amongst authors to exclude the OP_PUSHDATA opcode and the data length specifier from scripts. The BSV Editor does not follow that convention. The reason is that the BSV Editor is intended for the development of complex scripts, including those generated by high-level languages. It is therefore important that the script text accurately reflects the binary opcodes and data seen by the interpreter, and is not a reduced view. For example, the following P2PKH locking script would be displayed in the BSV Editor as The length specifier is denoted L20 rather than 20, which removes any possible ambiguity about its purpose. Saving Script TextNote that information is lost going from script language → binary script (opcodes + data) → script language. Hex is always used to describe the result of decoding a binary script. BSV Editor allows users to store the original script text with the transaction. To enable this feature, choose the Windows > Settings menu options and then enable the 'Save script text' checkbox. (Not currently implemented) Script LinksBSV Editor allows script objects to be stored searately from the transaction object; the transaction object stores a link to the script object rather than storing the script text. To link a transaction script to a script object, right click on the script you wish to link and chose the Link input[n] script menu option (as below). You will be asked for the name of the script object. Once a transaction script is linked to a script object, it cannot be updated using the transaction view. Instead edit and debug the script usin the script/spend view.   |
|||||||||
Copyright (c) Ventimore Ltd (UK), 2011, 2012, 2017, 2018. |