X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FKeysInterface.ts;h=c51f0b8b59d2aa323f2fa0936afaf86805a5a271;hb=22f5f4208b1f3b5542292250f1612b944f5cd7fd;hp=b4e1b71d4d9b59dd7a472de8bee08da746ec38b6;hpb=822471992c6bf6f9985e531cc5940e4cc35e3e4c;p=ldk-java diff --git a/ts/structs/KeysInterface.ts b/ts/structs/KeysInterface.ts index b4e1b71d..c51f0b8b 100644 --- a/ts/structs/KeysInterface.ts +++ b/ts/structs/KeysInterface.ts @@ -1,92 +1,118 @@ + import CommonBase from './CommonBase'; import * as bindings from '../bindings' // TODO: figure out location -public class KeysInterface extends CommonBase { - final bindings.LDKKeysInterface bindings_instance; - KeysInterface(Object _dummy, long ptr) { super(ptr); bindings_instance = null; } - private KeysInterface(bindings.LDKKeysInterface arg) { - super(bindings.LDKKeysInterface_new(arg)); - this.ptrs_to.add(arg); - this.bindings_instance = arg; - } - @Override @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - if (ptr != 0) { bindings.KeysInterface_free(ptr); } super.finalize(); - } - public static interface KeysInterfaceInterface { - byte[] get_node_secret(); - byte[] get_destination_script(); - byte[] get_shutdown_pubkey(); - ChannelKeys get_channel_keys(boolean inbound, long channel_value_satoshis); - byte[] get_secure_random_bytes(); - Result_ChanKeySignerDecodeErrorZ read_chan_signer(byte[] reader); - } - private static class LDKKeysInterfaceHolder { KeysInterface held; } - public static KeysInterface new_impl(KeysInterfaceInterface arg) { - final LDKKeysInterfaceHolder impl_holder = new LDKKeysInterfaceHolder(); - impl_holder.held = new KeysInterface(new bindings.LDKKeysInterface() { - @Override public byte[] get_node_secret() { - byte[] ret = arg.get_node_secret(); + + export class KeysInterface extends CommonBase { + + bindings_instance?: bindings.LDKKeysInterface; + + constructor(ptr?: number, arg?: bindings.LDKKeysInterface) { + if (Number.isFinite(ptr)) { + super(ptr); + this.bindings_instance = null; + } else { + // TODO: private constructor instantiation + super(bindings.LDKKeysInterface_new(arg)); + this.ptrs_to.push(arg); + + } + } + + protected finalize() { + if (this.ptr != 0) { + bindings.KeysInterface_free(this.ptr); + } + super.finalize(); + } + + static new_impl(arg: KeysInterfaceInterface): KeysInterface { + const impl_holder: LDKKeysInterfaceHolder = new LDKKeysInterfaceHolder(); + let structImplementation = { + // todo: in-line interface filling + get_node_secret (): Uint8Array { + Uint8Array ret = arg.get_node_secret(); return ret; - } - @Override public byte[] get_destination_script() { - byte[] ret = arg.get_destination_script(); + }, + + get_destination_script (): Uint8Array { + Uint8Array ret = arg.get_destination_script(); return ret; - } - @Override public byte[] get_shutdown_pubkey() { - byte[] ret = arg.get_shutdown_pubkey(); + }, + + get_shutdown_pubkey (): Uint8Array { + Uint8Array ret = arg.get_shutdown_pubkey(); return ret; - } - @Override public uint32_t get_channel_keys(boolean inbound, long channel_value_satoshis) { - ChannelKeys ret = arg.get_channel_keys(inbound, channel_value_satoshis); - uint32_t result = ret == null ? 0 : ret.ptr; + }, + + get_channel_keys (inbound: boolean, channel_value_satoshis: number): number { + ChannelKeys ret = arg.get_channel_keys(inbound, channel_value_satoshis); + result: number = ret == null ? 0 : ret.ptr; impl_holder.held.ptrs_to.add(ret); return result; - } - @Override public byte[] get_secure_random_bytes() { - byte[] ret = arg.get_secure_random_bytes(); + }, + + get_secure_random_bytes (): Uint8Array { + Uint8Array ret = arg.get_secure_random_bytes(); return ret; - } - @Override public uint32_t read_chan_signer(byte[] reader) { - Result_ChanKeySignerDecodeErrorZ ret = arg.read_chan_signer(reader); - uint32_t result = ret != null ? ret.ptr : 0; - ret.ptr = 0; + }, + + read_chan_signer (reader: Uint8Array): number { + Result_ChanKeySignerDecodeErrorZ ret = arg.read_chan_signer(reader); + result: number = ret != null ? ret.ptr : 0; return result; - } - }); - return impl_holder.held; - } - public byte[] get_node_secret() { - byte[] ret = bindings.KeysInterface_get_node_secret(this.ptr); + }, + + + }; + impl_holder.held = new KeysInterface (null, structImplementation); + } + } + + export interface KeysInterfaceInterface { + get_node_secret(): Uint8Array; + get_destination_script(): Uint8Array; + get_shutdown_pubkey(): Uint8Array; + get_channel_keys(inbound: boolean, channel_value_satoshis: number): ChannelKeys; + get_secure_random_bytes(): Uint8Array; + read_chan_signer(reader: Uint8Array): Result_ChanKeySignerDecodeErrorZ; + + } + + class LDKKeysInterfaceHolder { + held: KeysInterface; + } + public Uint8Array get_node_secret() { + Uint8Array ret = bindings.KeysInterface_get_node_secret(this.ptr); return ret; } - public byte[] get_destination_script() { - byte[] ret = bindings.KeysInterface_get_destination_script(this.ptr); + public Uint8Array get_destination_script() { + Uint8Array ret = bindings.KeysInterface_get_destination_script(this.ptr); return ret; } - public byte[] get_shutdown_pubkey() { - byte[] ret = bindings.KeysInterface_get_shutdown_pubkey(this.ptr); + public Uint8Array get_shutdown_pubkey() { + Uint8Array ret = bindings.KeysInterface_get_shutdown_pubkey(this.ptr); return ret; } - public ChannelKeys get_channel_keys(boolean inbound, long channel_value_satoshis) { - uint32_t ret = bindings.KeysInterface_get_channel_keys(this.ptr, inbound, channel_value_satoshis); + public ChannelKeys get_channel_keys(boolean inbound, number channel_value_satoshis) { + number ret = bindings.KeysInterface_get_channel_keys(this.ptr, inbound, channel_value_satoshis); ChannelKeys ret_hu_conv = new ChannelKeys(null, ret); ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } - public byte[] get_secure_random_bytes() { - byte[] ret = bindings.KeysInterface_get_secure_random_bytes(this.ptr); + public Uint8Array get_secure_random_bytes() { + Uint8Array ret = bindings.KeysInterface_get_secure_random_bytes(this.ptr); return ret; } - public Result_ChanKeySignerDecodeErrorZ read_chan_signer(byte[] reader) { - uint32_t ret = bindings.KeysInterface_read_chan_signer(this.ptr, reader); + public Result_ChanKeySignerDecodeErrorZ read_chan_signer(Uint8Array reader) { + number ret = bindings.KeysInterface_read_chan_signer(this.ptr, reader); Result_ChanKeySignerDecodeErrorZ ret_hu_conv = Result_ChanKeySignerDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }