]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/ChannelKeys.ts
Update auto-generated bindings with new upstream.
[ldk-java] / ts / structs / ChannelKeys.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class ChannelKeys extends CommonBase {
9
10                 bindings_instance?: bindings.LDKChannelKeys;
11
12                 constructor(ptr?: number, arg?: bindings.LDKChannelKeys, pubkeys?: ChannelPublicKeys) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKChannelKeys_new(arg, pubkeys == null ? 0 : pubkeys.ptr & ~1));
19                                         this.ptrs_to.push(arg);
20                                         this.ptrs_to.add(pubkeys);
21
22                                     }
23                 }
24
25                 protected finalize() {
26                     if (this.ptr != 0) {
27                         bindings.ChannelKeys_free(this.ptr);
28                     }
29                     super.finalize();
30                 }
31
32                 static new_impl(arg: ChannelKeysInterface, pubkeys: ChannelPublicKeys): ChannelKeys {
33                     const impl_holder: LDKChannelKeysHolder = new LDKChannelKeysHolder();
34                     let structImplementation = <bindings.LDKChannelKeys>{
35                         // todo: in-line interface filling
36                         get_per_commitment_point (idx: number): Uint8Array {
37                                                         Uint8Array ret = arg.get_per_commitment_point(idx);
38                                 return ret;
39                                                 },
40
41                                                 release_commitment_secret (idx: number): Uint8Array {
42                                                         Uint8Array ret = arg.release_commitment_secret(idx);
43                                 return ret;
44                                                 },
45
46                                                 key_derivation_params (): number {
47                                                         TwoTuple<Number, Number> ret = arg.key_derivation_params();
48                                 result: number = bindings.C2Tuple_u64u64Z_new(ret.a, ret.b);
49                                 return result;
50                                                 },
51
52                                                 sign_counterparty_commitment (commitment_tx: number): number {
53                                                         const commitment_tx_hu_conv: CommitmentTransaction = new CommitmentTransaction(null, commitment_tx);
54                                                         Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_counterparty_commitment(commitment_tx_hu_conv);
55                                 result: number = ret != null ? ret.ptr : 0;
56                                 return result;
57                                                 },
58
59                                                 sign_holder_commitment_and_htlcs (commitment_tx: number): number {
60                                                         const commitment_tx_hu_conv: HolderCommitmentTransaction = new HolderCommitmentTransaction(null, commitment_tx);
61                                                         Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret = arg.sign_holder_commitment_and_htlcs(commitment_tx_hu_conv);
62                                 result: number = ret != null ? ret.ptr : 0;
63                                 return result;
64                                                 },
65
66                                                 sign_justice_transaction (justice_tx: Uint8Array, input: number, amount: number, per_commitment_key: Uint8Array, htlc: number): number {
67                                                         const htlc_hu_conv: HTLCOutputInCommitment = new HTLCOutputInCommitment(null, htlc);
68                                                         Result_SignatureNoneZ ret = arg.sign_justice_transaction(justice_tx, input, amount, per_commitment_key, htlc_hu_conv);
69                                 result: number = ret != null ? ret.ptr : 0;
70                                 return result;
71                                                 },
72
73                                                 sign_counterparty_htlc_transaction (htlc_tx: Uint8Array, input: number, amount: number, per_commitment_point: Uint8Array, htlc: number): number {
74                                                         const htlc_hu_conv: HTLCOutputInCommitment = new HTLCOutputInCommitment(null, htlc);
75                                                         Result_SignatureNoneZ ret = arg.sign_counterparty_htlc_transaction(htlc_tx, input, amount, per_commitment_point, htlc_hu_conv);
76                                 result: number = ret != null ? ret.ptr : 0;
77                                 return result;
78                                                 },
79
80                                                 sign_closing_transaction (closing_tx: Uint8Array): number {
81                                                         Result_SignatureNoneZ ret = arg.sign_closing_transaction(closing_tx);
82                                 result: number = ret != null ? ret.ptr : 0;
83                                 return result;
84                                                 },
85
86                                                 sign_channel_announcement (msg: number): number {
87                                                         const msg_hu_conv: UnsignedChannelAnnouncement = new UnsignedChannelAnnouncement(null, msg);
88                                                         Result_SignatureNoneZ ret = arg.sign_channel_announcement(msg_hu_conv);
89                                 result: number = ret != null ? ret.ptr : 0;
90                                 return result;
91                                                 },
92
93                                                 ready_channel (channel_parameters: number): void {
94                                                         const channel_parameters_hu_conv: ChannelTransactionParameters = new ChannelTransactionParameters(null, channel_parameters);
95                                                         arg.ready_channel(channel_parameters_hu_conv);
96                                                 },
97
98                                                 write (): Uint8Array {
99                                                         Uint8Array ret = arg.write();
100                                 return ret;
101                                                 },
102
103                                                 
104                     };
105                     impl_holder.held = new ChannelKeys (null, structImplementation, pubkeys);
106                 }
107             }
108
109             export interface ChannelKeysInterface {
110                 get_per_commitment_point(idx: number): Uint8Array;
111                                 release_commitment_secret(idx: number): Uint8Array;
112                                 key_derivation_params(): TwoTuple<Number, Number>;
113                                 sign_counterparty_commitment(commitment_tx: CommitmentTransaction): Result_C2Tuple_SignatureCVec_SignatureZZNoneZ;
114                                 sign_holder_commitment_and_htlcs(commitment_tx: HolderCommitmentTransaction): Result_C2Tuple_SignatureCVec_SignatureZZNoneZ;
115                                 sign_justice_transaction(justice_tx: Uint8Array, input: number, amount: number, per_commitment_key: Uint8Array, htlc: HTLCOutputInCommitment): Result_SignatureNoneZ;
116                                 sign_counterparty_htlc_transaction(htlc_tx: Uint8Array, input: number, amount: number, per_commitment_point: Uint8Array, htlc: HTLCOutputInCommitment): Result_SignatureNoneZ;
117                                 sign_closing_transaction(closing_tx: Uint8Array): Result_SignatureNoneZ;
118                                 sign_channel_announcement(msg: UnsignedChannelAnnouncement): Result_SignatureNoneZ;
119                                 ready_channel(channel_parameters: ChannelTransactionParameters): void;
120                                 write(): Uint8Array;
121                                 
122             }
123
124             class LDKChannelKeysHolder {
125                 held: ChannelKeys;
126             }
127         public Uint8Array get_per_commitment_point(number idx) {
128                 Uint8Array ret = bindings.ChannelKeys_get_per_commitment_point(this.ptr, idx);
129                 return ret;
130         }
131
132         public Uint8Array release_commitment_secret(number idx) {
133                 Uint8Array ret = bindings.ChannelKeys_release_commitment_secret(this.ptr, idx);
134                 return ret;
135         }
136
137         public TwoTuple<Number, Number> key_derivation_params() {
138                 number ret = bindings.ChannelKeys_key_derivation_params(this.ptr);
139                 number ret_a = bindings.LDKC2Tuple_u64u64Z_get_a(ret);
140                 number ret_b = bindings.LDKC2Tuple_u64u64Z_get_b(ret);
141                 TwoTuple<Number, Number> ret_conv = new TwoTuple<Number, Number>(ret_a, ret_b, () -> {
142                         bindings.C2Tuple_u64u64Z_free(ret);
143                 });
144                 return ret_conv;
145         }
146
147         public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment(CommitmentTransaction commitment_tx) {
148                 number ret = bindings.ChannelKeys_sign_counterparty_commitment(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1);
149                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
150                 this.ptrs_to.add(commitment_tx);
151                 return ret_hu_conv;
152         }
153
154         public Result_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs(HolderCommitmentTransaction commitment_tx) {
155                 number ret = bindings.ChannelKeys_sign_holder_commitment_and_htlcs(this.ptr, commitment_tx == null ? 0 : commitment_tx.ptr & ~1);
156                 Result_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_hu_conv = Result_C2Tuple_SignatureCVec_SignatureZZNoneZ.constr_from_ptr(ret);
157                 this.ptrs_to.add(commitment_tx);
158                 return ret_hu_conv;
159         }
160
161         public Result_SignatureNoneZ sign_justice_transaction(Uint8Array justice_tx, number input, number amount, Uint8Array per_commitment_key, HTLCOutputInCommitment htlc) {
162                 number ret = bindings.ChannelKeys_sign_justice_transaction(this.ptr, justice_tx, input, amount, per_commitment_key, htlc == null ? 0 : htlc.ptr & ~1);
163                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
164                 this.ptrs_to.add(htlc);
165                 return ret_hu_conv;
166         }
167
168         public Result_SignatureNoneZ sign_counterparty_htlc_transaction(Uint8Array htlc_tx, number input, number amount, Uint8Array per_commitment_point, HTLCOutputInCommitment htlc) {
169                 number ret = bindings.ChannelKeys_sign_counterparty_htlc_transaction(this.ptr, htlc_tx, input, amount, per_commitment_point, htlc == null ? 0 : htlc.ptr & ~1);
170                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
171                 this.ptrs_to.add(htlc);
172                 return ret_hu_conv;
173         }
174
175         public Result_SignatureNoneZ sign_closing_transaction(Uint8Array closing_tx) {
176                 number ret = bindings.ChannelKeys_sign_closing_transaction(this.ptr, closing_tx);
177                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
178                 return ret_hu_conv;
179         }
180
181         public Result_SignatureNoneZ sign_channel_announcement(UnsignedChannelAnnouncement msg) {
182                 number ret = bindings.ChannelKeys_sign_channel_announcement(this.ptr, msg == null ? 0 : msg.ptr & ~1);
183                 Result_SignatureNoneZ ret_hu_conv = Result_SignatureNoneZ.constr_from_ptr(ret);
184                 this.ptrs_to.add(msg);
185                 return ret_hu_conv;
186         }
187
188         public void ready_channel(ChannelTransactionParameters channel_parameters) {
189                 bindings.ChannelKeys_ready_channel(this.ptr, channel_parameters == null ? 0 : channel_parameters.ptr & ~1);
190                 this.ptrs_to.add(channel_parameters);
191         }
192
193         public Uint8Array write() {
194                 Uint8Array ret = bindings.ChannelKeys_write(this.ptr);
195                 return ret;
196         }
197
198         public ChannelPublicKeys get_pubkeys() {
199                 number ret = bindings.ChannelKeys_get_pubkeys(this.ptr);
200                 const ret_hu_conv: ChannelPublicKeys = new ChannelPublicKeys(null, ret);
201                 ret_hu_conv.ptrs_to.add(this);
202                 return ret_hu_conv;
203         }
204
205         public ChannelKeys clone() {
206                 number ret = bindings.ChannelKeys_clone(this.ptr);
207                 ChannelKeys ret_hu_conv = new ChannelKeys(null, ret);
208                 ret_hu_conv.ptrs_to.add(this);
209                 return ret_hu_conv;
210         }
211
212 }