Skip to content

Commit ca7be56

Browse files
committed
add: hash method for NativeScript
1 parent 4c93d39 commit ca7be56

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

conway-cddl/yaml/conway.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,15 @@ NativeScript:
22052205
- name: timelock_expiry
22062206
tag: 5
22072207
value: TimelockExpiry
2208+
extra_methods: |
2209+
hash(): ScriptHash {
2210+
const thisBytes = this.to_bytes();
2211+
let bytes = new Uint8Array(thisBytes.length + 1);
2212+
bytes[0] = 0;
2213+
bytes.set(thisBytes, 1);
2214+
let hash_bytes = cdlCrypto.blake2b224(bytes);
2215+
return new ScriptHash(hash_bytes);
2216+
}
22082217
22092218
ScriptPubkey:
22102219
type: newtype

src/generated.ts

+9
Original file line numberDiff line numberDiff line change
@@ -8726,6 +8726,15 @@ export class NativeScript {
87268726
clone(path: string[]): NativeScript {
87278727
return NativeScript.from_bytes(this.to_bytes(), path);
87288728
}
8729+
8730+
hash(): ScriptHash {
8731+
const thisBytes = this.to_bytes();
8732+
let bytes = new Uint8Array(thisBytes.length + 1);
8733+
bytes[0] = 0;
8734+
bytes.set(thisBytes, 1);
8735+
let hash_bytes = cdlCrypto.blake2b224(bytes);
8736+
return new ScriptHash(hash_bytes);
8737+
}
87298738
}
87308739

87318740
export class NativeScriptRefInput {

0 commit comments

Comments
 (0)