X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-java;a=blobdiff_plain;f=typescript_strings.py;h=092a9e152631388dbd97c99f8d3ea064db7f989e;hp=f181f56f83ba9388f04add3ecb2e5750ea00906f;hb=4f95adad9cbb821f489d89f73d3e493933ba60fe;hpb=41fd4b2fbfdaf80ed7f44df6fd4d6f64b9fc8997 diff --git a/typescript_strings.py b/typescript_strings.py index f181f56f..092a9e15 100644 --- a/typescript_strings.py +++ b/typescript_strings.py @@ -36,7 +36,7 @@ class Consts: self.bindings_header = """ import * as version from './version.mjs'; -import { UInt5 } from './structs/CommonBase.mjs'; +import { UInt5, WitnessVersion } from './structs/CommonBase.mjs'; const imports: any = {}; imports.env = {}; @@ -149,6 +149,17 @@ export function uint5ArrToBytes(inputArray: Array): Uint8Array { return arr; } +/* @internal */ +export function WitnessVersionArrToBytes(inputArray: Array): Uint8Array { + const arr = new Uint8Array(inputArray.length); + for (var i = 0; i < inputArray.length; i++) { + arr[i] = inputArray[i].getVal(); + } + return arr; +} + + + /* @internal */ export function encodeUint8Array (inputArray: Uint8Array): number { const cArrayPointer = wasm.TS_malloc(inputArray.length + 4); @@ -327,6 +338,15 @@ export class UInt5 { } } +export class WitnessVersion { + public constructor(private val: number) { + if (val > 16 || val < 0) throw new Error("WitnessVersion value is out of range"); + } + public getVal(): number { + return this.val; + } +} + export class UnqualifiedError { public constructor(val: number) {} } @@ -596,7 +616,7 @@ jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() { }""" self.hu_struct_file_prefix = """ -import { CommonBase, UInt5, UnqualifiedError } from './CommonBase.mjs'; +import { CommonBase, UInt5, WitnessVersion, UnqualifiedError } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' """