]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/KeysInterface.ts
Merge pull request #69 from TheBlueMatt/main
[ldk-java] / ts / structs / KeysInterface.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class KeysInterface extends CommonBase {
9
10                 bindings_instance?: bindings.LDKKeysInterface;
11
12                 constructor(ptr?: number, arg?: bindings.LDKKeysInterface) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKKeysInterface_new(arg));
19                                         this.ptrs_to.push(arg);
20                                         
21                                     }
22                 }
23
24                 protected finalize() {
25                     if (this.ptr != 0) {
26                         bindings.KeysInterface_free(this.ptr);
27                     }
28                     super.finalize();
29                 }
30
31                 static new_impl(arg: KeysInterfaceInterface): KeysInterface {
32                     const impl_holder: LDKKeysInterfaceHolder = new LDKKeysInterfaceHolder();
33                     let structImplementation = <bindings.LDKKeysInterface>{
34                         // todo: in-line interface filling
35                         get_node_secret (): Uint8Array {
36                                                         Uint8Array ret = arg.get_node_secret();
37                                 result: Uint8Array = InternalUtils.check_arr_len(ret, 32);
38                                 return result;
39                                                 },
40
41                                                 get_destination_script (): Uint8Array {
42                                                         Uint8Array ret = arg.get_destination_script();
43                                 return ret;
44                                                 },
45
46                                                 get_shutdown_scriptpubkey (): number {
47                                                         ShutdownScript ret = arg.get_shutdown_scriptpubkey();
48                                 result: number = ret == null ? 0 : ret.clone_ptr();
49                                 return result;
50                                                 },
51
52                                                 get_channel_signer (inbound: boolean, channel_value_satoshis: number): number {
53                                                         Sign ret = arg.get_channel_signer(inbound, channel_value_satoshis);
54                                 result: number = ret == null ? 0 : ret.clone_ptr();
55                                 impl_holder.held.ptrs_to.add(ret);
56                                 return result;
57                                                 },
58
59                                                 get_secure_random_bytes (): Uint8Array {
60                                                         Uint8Array ret = arg.get_secure_random_bytes();
61                                 result: Uint8Array = InternalUtils.check_arr_len(ret, 32);
62                                 return result;
63                                                 },
64
65                                                 read_chan_signer (reader: Uint8Array): number {
66                                                         Result_SignDecodeErrorZ ret = arg.read_chan_signer(reader);
67                                 result: number = ret == null ? 0 : ret.clone_ptr();
68                                 return result;
69                                                 },
70
71                                                 sign_invoice (invoice_preimage: Uint8Array): number {
72                                                         Result_RecoverableSignatureNoneZ ret = arg.sign_invoice(invoice_preimage);
73                                 result: number = ret == null ? 0 : ret.clone_ptr();
74                                 return result;
75                                                 },
76
77                                                 get_inbound_payment_key_material (): Uint8Array {
78                                                         Uint8Array ret = arg.get_inbound_payment_key_material();
79                                 result: Uint8Array = InternalUtils.check_arr_len(ret, 32);
80                                 return result;
81                                                 },
82
83                                                 
84                     };
85                     impl_holder.held = new KeysInterface (null, structImplementation);
86                 }
87             }
88
89             export interface KeysInterfaceInterface {
90                 get_node_secret(): Uint8Array;
91                                 get_destination_script(): Uint8Array;
92                                 get_shutdown_scriptpubkey(): ShutdownScript;
93                                 get_channel_signer(inbound: boolean, channel_value_satoshis: number): Sign;
94                                 get_secure_random_bytes(): Uint8Array;
95                                 read_chan_signer(reader: Uint8Array): Result_SignDecodeErrorZ;
96                                 sign_invoice(invoice_preimage: Uint8Array): Result_RecoverableSignatureNoneZ;
97                                 get_inbound_payment_key_material(): Uint8Array;
98                                 
99             }
100
101             class LDKKeysInterfaceHolder {
102                 held: KeysInterface;
103             }
104         public Uint8Array get_node_secret() {
105                 Uint8Array ret = bindings.KeysInterface_get_node_secret(this.ptr);
106                 return ret;
107         }
108
109         public Uint8Array get_destination_script() {
110                 Uint8Array ret = bindings.KeysInterface_get_destination_script(this.ptr);
111                 return ret;
112         }
113
114         public ShutdownScript get_shutdown_scriptpubkey() {
115                 number ret = bindings.KeysInterface_get_shutdown_scriptpubkey(this.ptr);
116                 const ret_hu_conv: ShutdownScript = new ShutdownScript(null, ret);
117                 ret_hu_conv.ptrs_to.add(this);
118                 return ret_hu_conv;
119         }
120
121         public Sign get_channel_signer(boolean inbound, number channel_value_satoshis) {
122                 number ret = bindings.KeysInterface_get_channel_signer(this.ptr, inbound, channel_value_satoshis);
123                 Sign ret_hu_conv = new Sign(null, ret);
124                 ret_hu_conv.ptrs_to.add(this);
125                 return ret_hu_conv;
126         }
127
128         public Uint8Array get_secure_random_bytes() {
129                 Uint8Array ret = bindings.KeysInterface_get_secure_random_bytes(this.ptr);
130                 return ret;
131         }
132
133         public Result_SignDecodeErrorZ read_chan_signer(Uint8Array reader) {
134                 number ret = bindings.KeysInterface_read_chan_signer(this.ptr, reader);
135                 Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
136                 return ret_hu_conv;
137         }
138
139         public Result_RecoverableSignatureNoneZ sign_invoice(Uint8Array invoice_preimage) {
140                 number ret = bindings.KeysInterface_sign_invoice(this.ptr, invoice_preimage);
141                 Result_RecoverableSignatureNoneZ ret_hu_conv = Result_RecoverableSignatureNoneZ.constr_from_ptr(ret);
142                 return ret_hu_conv;
143         }
144
145         public Uint8Array get_inbound_payment_key_material() {
146                 Uint8Array ret = bindings.KeysInterface_get_inbound_payment_key_material(this.ptr);
147                 return ret;
148         }
149
150 }