]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/KeysInterface.ts
Update bindings to latest upstream + ChannelMonitor_clone patch
[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_pubkey (): Uint8Array {
46                                                         Uint8Array ret = arg.get_shutdown_pubkey();
47                                 return ret;
48                                                 },
49
50                                                 get_channel_signer (inbound: boolean, channel_value_satoshis: number): number {
51                                                         Sign ret = arg.get_channel_signer(inbound, channel_value_satoshis);
52                                 result: number = ret == null ? 0 : ret.ptr;
53                                 impl_holder.held.ptrs_to.add(ret);
54                                 return result;
55                                                 },
56
57                                                 get_secure_random_bytes (): Uint8Array {
58                                                         Uint8Array ret = arg.get_secure_random_bytes();
59                                 return ret;
60                                                 },
61
62                                                 read_chan_signer (reader: Uint8Array): number {
63                                                         Result_SignDecodeErrorZ ret = arg.read_chan_signer(reader);
64                                 result: number = ret != null ? ret.ptr : 0;
65                                 return result;
66                                                 },
67
68                                                 
69                     };
70                     impl_holder.held = new KeysInterface (null, structImplementation);
71                 }
72             }
73
74             export interface KeysInterfaceInterface {
75                 get_node_secret(): Uint8Array;
76                                 get_destination_script(): Uint8Array;
77                                 get_shutdown_pubkey(): Uint8Array;
78                                 get_channel_signer(inbound: boolean, channel_value_satoshis: number): Sign;
79                                 get_secure_random_bytes(): Uint8Array;
80                                 read_chan_signer(reader: Uint8Array): Result_SignDecodeErrorZ;
81                                 
82             }
83
84             class LDKKeysInterfaceHolder {
85                 held: KeysInterface;
86             }
87         public Uint8Array get_node_secret() {
88                 Uint8Array ret = bindings.KeysInterface_get_node_secret(this.ptr);
89                 return ret;
90         }
91
92         public Uint8Array get_destination_script() {
93                 Uint8Array ret = bindings.KeysInterface_get_destination_script(this.ptr);
94                 return ret;
95         }
96
97         public Uint8Array get_shutdown_pubkey() {
98                 Uint8Array ret = bindings.KeysInterface_get_shutdown_pubkey(this.ptr);
99                 return ret;
100         }
101
102         public Sign get_channel_signer(boolean inbound, number channel_value_satoshis) {
103                 number ret = bindings.KeysInterface_get_channel_signer(this.ptr, inbound, channel_value_satoshis);
104                 Sign ret_hu_conv = new Sign(null, ret);
105                 ret_hu_conv.ptrs_to.add(this);
106                 return ret_hu_conv;
107         }
108
109         public Uint8Array get_secure_random_bytes() {
110                 Uint8Array ret = bindings.KeysInterface_get_secure_random_bytes(this.ptr);
111                 return ret;
112         }
113
114         public Result_SignDecodeErrorZ read_chan_signer(Uint8Array reader) {
115                 number ret = bindings.KeysInterface_read_chan_signer(this.ptr, reader);
116                 Result_SignDecodeErrorZ ret_hu_conv = Result_SignDecodeErrorZ.constr_from_ptr(ret);
117                 return ret_hu_conv;
118         }
119
120 }