Chore/base configurations
This commit is contained in:
13
source/script.ts
Normal file
13
source/script.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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);
|
||||
};
|
||||
Reference in New Issue
Block a user