d199662d5790ab847c1835fbf51a61519734a1de
[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                                 return ret;
38                                                 },
39
40                                                 get_destination_script (): Uint8Array {
41                                                         Uint8Array ret = arg.get_destination_script();
42                                 return ret;
43                                                 },
44
45                                                 get_shutdown_scriptpubkey (): number {
46                                                         ShutdownScript ret = arg.get_shutdown_scriptpubkey();
47                                 result: number = ret == null ? 0 : ret.ptr & ~1;
48                                 impl_holder.held.ptrs_to.add(ret);
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.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                                 return ret;
62                                                 },
63
64                                                 read_chan_signer (reader: Uint8Array): number {
65                                                         Result_SignDecodeErrorZ ret = arg.read_chan_signer(reader);
66                                 result: number = ret != null ? ret.ptr : 0;
67                                 return result;
68                                                 },
69
70                                                 sign_invoice (invoice_preimage: Uint8Array): number {
71                                                         Result_RecoverableSignatureNoneZ ret = arg.sign_invoice(invoice_preimage);
72                                 result: number = ret != null ? ret.ptr : 0;
73                                 return result;
74                                                 },
75
76                                                 
77                     };
78                     impl_holder.held = new KeysInterface (null, structImplementation);
79                 }
80             }
81
82             export interface KeysInterfaceInterface {
83                 get_node_secret(): Uint8Array;
84                                 get_destination_script(): Uint8Array;
85                                 get_shutdown_scriptpubkey(): ShutdownScript;
86                                 get_channel_signer(inbound: boolean, channel_value_satoshis: number): Sign;
87                                 get_secure_random_bytes(): Uint8Array;
88                                 read_chan_signer(reader: Uint8Array): Result_SignDecodeErrorZ;
89                                 sign_invoice(invoice_preimage: Uint8Array): Result_RecoverableSignatureNoneZ;
90                                 
91             }
92
93             class LDKKeysInterfaceHolder {
94                 held: KeysInterface;
95             }
96         public Uint8Array get_node_secret() {
97                 Uint8Array ret = bindings.KeysInterface_get_node_secret(this.ptr);
98                 return ret;
99         }
100
101         public Uint8Array get_destination_script() {
102                 Uint8Array ret = bindings.KeysInterface_get_destination_script(this.ptr);
103                 return ret;
104         }
105
106         public ShutdownScript get_shutdown_scriptpubkey() {
107                 number ret = bindings.KeysInterface_get_shutdown_scriptpubkey(this.ptr);
108                 const ret_hu_conv: ShutdownScript = new ShutdownScript(null, ret);
109                 ret_hu_conv.ptrs_to.add(this);
110                 return ret_hu_conv;
111         }
112
113         public Sign get_channel_signer(boolean inbound, number channel_value_satoshis) {
114                 number ret = bindings.KeysInterface_get_channel_signer(this.ptr, inbound, channel_value_satoshis);
115                 Sign ret_hu_conv = new Sign(null, ret);
116                 ret_hu_conv.ptrs_to.add(this);
117                 return ret_hu_conv;
118         }
119
120         public Uint8Array get_secure_random_bytes() {
121                 Uint8Array ret = bindings.KeysInterface_get_secure_random_bytes(this.ptr);
122                 return ret;
123         }
124
125         public Result_SignDecodeErrorZ read_chan_signer(Uint8Array reader) {
126                 number ret = bindings.KeysInterface_read_chan_signer(this.ptr, reader);
127                 Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
128                 return ret_hu_conv;
129         }
130
131         public Result_RecoverableSignatureNoneZ sign_invoice(Uint8Array invoice_preimage) {
132                 number ret = bindings.KeysInterface_sign_invoice(this.ptr, invoice_preimage);
133                 Result_RecoverableSignatureNoneZ ret_hu_conv = Result_RecoverableSignatureNoneZ.constr_from_ptr(ret);
134                 return ret_hu_conv;
135         }
136
137 }