Files
xo-cash-utils/source/script.ts
2026-01-25 12:51:34 +00:00

14 lines
394 B
TypeScript

import { binToHex, sha256 } from '@bitauth/libauth';
/**
* Converts a script to a scriptHash.
* @param {Uint8Array} script - The script to convert.
* @returns {string} The scriptHash as a hexadecimal string.
*/
export const scriptToScriptHash = (script: Uint8Array): string => {
const hash = sha256.hash(script);
const reversed = hash.reverse();
return binToHex(reversed);
};