14 lines
394 B
TypeScript
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);
|
|
};
|