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

Function scriptToAddress

packages/cashscript/src/utils.ts:287–297  ·  view source on GitHub ↗
(
  script: Script, network: string, addressType: AddressType, tokenSupport: boolean,
)

Source from the content-addressed store, hash-verified

285}
286
287export function scriptToAddress(
288 script: Script, network: string, addressType: AddressType, tokenSupport: boolean,
289): string {
290 const bytecode = scriptToP2SHLockingBytecode(script, addressType);
291 const prefix = getNetworkPrefix(network);
292
293 const result = lockingBytecodeToCashAddress({ bytecode, prefix, tokenSupport });
294 if (typeof result === 'string') throw new Error(result);
295
296 return result.address;
297}
298
299export function scriptToP2SHLockingBytecode(script: Script, addressType: AddressType): Uint8Array {
300 const scriptBytecode = scriptToBytecode(script);

Callers 2

util.test.tsFile · 0.85
constructorMethod · 0.85

Calls 2

getNetworkPrefixFunction · 0.85

Tested by

no test coverage detected