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

Function encodeNullDataScript

packages/utils/src/script.ts:131–142  ·  view source on GitHub ↗
(chunks: OpOrData[])

Source from the content-addressed store, hash-verified

129
130// For encoding OP_RETURN data (doesn't require BIP62.3 / MINIMALDATA)
131export function encodeNullDataScript(chunks: OpOrData[]): Uint8Array {
132 return flattenBinArray(
133 chunks.map((chunk) => {
134 if (typeof chunk === 'number') {
135 return new Uint8Array([chunk]);
136 }
137
138 const pushdataOpcode = getPushDataOpcode(chunk);
139 return new Uint8Array([...pushdataOpcode, ...chunk]);
140 }),
141 );
142}
143
144function getPushDataOpcode(data: Uint8Array): Uint8Array {
145 const { byteLength } = data;

Callers 2

createOpReturnOutputFunction · 0.90
script.test.tsFile · 0.85

Calls 1

getPushDataOpcodeFunction · 0.85

Tested by

no test coverage detected