MCPcopy Create free account
hub / github.com/CashScript/cashscript / scriptToBytecode

Function scriptToBytecode

packages/utils/src/script.ts:39–51  ·  view source on GitHub ↗
(script: Script)

Source from the content-addressed store, hash-verified

37}
38
39export function scriptToBytecode(script: Script): Uint8Array {
40 // Convert the script elements to AuthenticationInstructions
41 const instructions = script.map((opOrData) => {
42 if (typeof opOrData === 'number') {
43 return { opcode: opOrData };
44 }
45
46 return decodeAuthenticationInstructions(encodeDataPush(opOrData))[0];
47 });
48
49 // Convert the AuthenticationInstructions to bytecode
50 return encodeAuthenticationInstructions(instructions);
51}
52
53export function bytecodeToScript(bytecode: Uint8Array): Script {
54 // Convert the bytecode to AuthenticationInstructions

Callers 11

constructorMethod · 0.90
createUnlockingBytecodeFunction · 0.90
unlockP2PKHMethod · 0.90
runFunction · 0.90
compileStringFunction · 0.90
script.test.tsFile · 0.85
scriptToAsmFunction · 0.85
scriptToBitAuthAsmFunction · 0.85
calculateBytesizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected