Merge pull request #69 from TheBlueMatt/main
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 void *malloc(size_t size);
18 void free(void *ptr);
19
20 #define MALLOC(a, _) malloc(a)
21 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
22 #define DO_ASSERT(a) (void)(a)
23 #define CHECK(a)
24 #define CHECK_ACCESS(p)
25 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
26
27 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
28 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
29 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
30 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
31
32 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
33
34 typedef uint32_t int64_tArray;
35 typedef uint32_t int8_tArray;
36 typedef uint32_t uint32_tArray;
37 typedef uint32_t ptrArray;
38 typedef uint32_t jstring;
39
40 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
41         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
42         elems[0] = arr_len;
43         return (uint32_t)elems;
44 }
45
46 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
47         char* err_buf = MALLOC(len + 4, "str conv buf");
48         *((uint32_t*)err_buf) = len;
49         memcpy(err_buf + 4, chars, len);
50         return (uint32_t) err_buf;
51 }
52 static inline LDKStr str_ref_to_owned_c(jstring str) {
53         uint32_t *str_len = (uint32_t*)str;
54         char* newchars = MALLOC(*str_len + 1, "String chars");
55         memcpy(newchars, (const char*)(str + 4), *str_len);
56         newchars[*str_len] = 0;
57         LDKStr res= {
58                 .chars = newchars,
59                 .len = *str_len,
60                 .chars_is_owned = true
61         };
62         return res;
63 }
64
65 typedef bool jboolean;
66
67 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
68         return (uint32_t)MALLOC(size, "JS-Called malloc");
69 }
70 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
71         FREE((void*)ptr);
72 }
73 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
74 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
75         switch (ord) {
76                 case 0: return LDKAccessError_UnknownChain;
77                 case 1: return LDKAccessError_UnknownTx;
78         }
79         abort();
80 }
81 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
82         switch (val) {
83                 case LDKAccessError_UnknownChain: return 0;
84                 case LDKAccessError_UnknownTx: return 1;
85                 default: abort();
86         }
87 }
88 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
89         switch (ord) {
90                 case 0: return LDKCOption_NoneZ_Some;
91                 case 1: return LDKCOption_NoneZ_None;
92         }
93         abort();
94 }
95 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
96         switch (val) {
97                 case LDKCOption_NoneZ_Some: return 0;
98                 case LDKCOption_NoneZ_None: return 1;
99                 default: abort();
100         }
101 }
102 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
103         switch (ord) {
104                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
105                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
106         }
107         abort();
108 }
109 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
110         switch (val) {
111                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
112                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
113                 default: abort();
114         }
115 }
116 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
117         switch (ord) {
118                 case 0: return LDKConfirmationTarget_Background;
119                 case 1: return LDKConfirmationTarget_Normal;
120                 case 2: return LDKConfirmationTarget_HighPriority;
121         }
122         abort();
123 }
124 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
125         switch (val) {
126                 case LDKConfirmationTarget_Background: return 0;
127                 case LDKConfirmationTarget_Normal: return 1;
128                 case LDKConfirmationTarget_HighPriority: return 2;
129                 default: abort();
130         }
131 }
132 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
133         switch (ord) {
134                 case 0: return LDKCreationError_DescriptionTooLong;
135                 case 1: return LDKCreationError_RouteTooLong;
136                 case 2: return LDKCreationError_TimestampOutOfBounds;
137                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
138                 case 4: return LDKCreationError_InvalidAmount;
139         }
140         abort();
141 }
142 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
143         switch (val) {
144                 case LDKCreationError_DescriptionTooLong: return 0;
145                 case LDKCreationError_RouteTooLong: return 1;
146                 case LDKCreationError_TimestampOutOfBounds: return 2;
147                 case LDKCreationError_ExpiryTimeOutOfBounds: return 3;
148                 case LDKCreationError_InvalidAmount: return 4;
149                 default: abort();
150         }
151 }
152 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
153         switch (ord) {
154                 case 0: return LDKCurrency_Bitcoin;
155                 case 1: return LDKCurrency_BitcoinTestnet;
156                 case 2: return LDKCurrency_Regtest;
157                 case 3: return LDKCurrency_Simnet;
158                 case 4: return LDKCurrency_Signet;
159         }
160         abort();
161 }
162 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
163         switch (val) {
164                 case LDKCurrency_Bitcoin: return 0;
165                 case LDKCurrency_BitcoinTestnet: return 1;
166                 case LDKCurrency_Regtest: return 2;
167                 case LDKCurrency_Simnet: return 3;
168                 case LDKCurrency_Signet: return 4;
169                 default: abort();
170         }
171 }
172 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
173         switch (ord) {
174                 case 0: return LDKIOError_NotFound;
175                 case 1: return LDKIOError_PermissionDenied;
176                 case 2: return LDKIOError_ConnectionRefused;
177                 case 3: return LDKIOError_ConnectionReset;
178                 case 4: return LDKIOError_ConnectionAborted;
179                 case 5: return LDKIOError_NotConnected;
180                 case 6: return LDKIOError_AddrInUse;
181                 case 7: return LDKIOError_AddrNotAvailable;
182                 case 8: return LDKIOError_BrokenPipe;
183                 case 9: return LDKIOError_AlreadyExists;
184                 case 10: return LDKIOError_WouldBlock;
185                 case 11: return LDKIOError_InvalidInput;
186                 case 12: return LDKIOError_InvalidData;
187                 case 13: return LDKIOError_TimedOut;
188                 case 14: return LDKIOError_WriteZero;
189                 case 15: return LDKIOError_Interrupted;
190                 case 16: return LDKIOError_Other;
191                 case 17: return LDKIOError_UnexpectedEof;
192         }
193         abort();
194 }
195 static inline int32_t LDKIOError_to_js(LDKIOError val) {
196         switch (val) {
197                 case LDKIOError_NotFound: return 0;
198                 case LDKIOError_PermissionDenied: return 1;
199                 case LDKIOError_ConnectionRefused: return 2;
200                 case LDKIOError_ConnectionReset: return 3;
201                 case LDKIOError_ConnectionAborted: return 4;
202                 case LDKIOError_NotConnected: return 5;
203                 case LDKIOError_AddrInUse: return 6;
204                 case LDKIOError_AddrNotAvailable: return 7;
205                 case LDKIOError_BrokenPipe: return 8;
206                 case LDKIOError_AlreadyExists: return 9;
207                 case LDKIOError_WouldBlock: return 10;
208                 case LDKIOError_InvalidInput: return 11;
209                 case LDKIOError_InvalidData: return 12;
210                 case LDKIOError_TimedOut: return 13;
211                 case LDKIOError_WriteZero: return 14;
212                 case LDKIOError_Interrupted: return 15;
213                 case LDKIOError_Other: return 16;
214                 case LDKIOError_UnexpectedEof: return 17;
215                 default: abort();
216         }
217 }
218 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
219         switch (ord) {
220                 case 0: return LDKLevel_Gossip;
221                 case 1: return LDKLevel_Trace;
222                 case 2: return LDKLevel_Debug;
223                 case 3: return LDKLevel_Info;
224                 case 4: return LDKLevel_Warn;
225                 case 5: return LDKLevel_Error;
226         }
227         abort();
228 }
229 static inline int32_t LDKLevel_to_js(LDKLevel val) {
230         switch (val) {
231                 case LDKLevel_Gossip: return 0;
232                 case LDKLevel_Trace: return 1;
233                 case LDKLevel_Debug: return 2;
234                 case LDKLevel_Info: return 3;
235                 case LDKLevel_Warn: return 4;
236                 case LDKLevel_Error: return 5;
237                 default: abort();
238         }
239 }
240 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
241         switch (ord) {
242                 case 0: return LDKNetwork_Bitcoin;
243                 case 1: return LDKNetwork_Testnet;
244                 case 2: return LDKNetwork_Regtest;
245                 case 3: return LDKNetwork_Signet;
246         }
247         abort();
248 }
249 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
250         switch (val) {
251                 case LDKNetwork_Bitcoin: return 0;
252                 case LDKNetwork_Testnet: return 1;
253                 case LDKNetwork_Regtest: return 2;
254                 case LDKNetwork_Signet: return 3;
255                 default: abort();
256         }
257 }
258 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
259         switch (ord) {
260                 case 0: return LDKSecp256k1Error_IncorrectSignature;
261                 case 1: return LDKSecp256k1Error_InvalidMessage;
262                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
263                 case 3: return LDKSecp256k1Error_InvalidSignature;
264                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
265                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
266                 case 6: return LDKSecp256k1Error_InvalidTweak;
267                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
268                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
269         }
270         abort();
271 }
272 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
273         switch (val) {
274                 case LDKSecp256k1Error_IncorrectSignature: return 0;
275                 case LDKSecp256k1Error_InvalidMessage: return 1;
276                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
277                 case LDKSecp256k1Error_InvalidSignature: return 3;
278                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
279                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
280                 case LDKSecp256k1Error_InvalidTweak: return 6;
281                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
282                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
283                 default: abort();
284         }
285 }
286 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
287         switch (ord) {
288                 case 0: return LDKSemanticError_NoPaymentHash;
289                 case 1: return LDKSemanticError_MultiplePaymentHashes;
290                 case 2: return LDKSemanticError_NoDescription;
291                 case 3: return LDKSemanticError_MultipleDescriptions;
292                 case 4: return LDKSemanticError_NoPaymentSecret;
293                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
294                 case 6: return LDKSemanticError_InvalidFeatures;
295                 case 7: return LDKSemanticError_InvalidRecoveryId;
296                 case 8: return LDKSemanticError_InvalidSignature;
297                 case 9: return LDKSemanticError_ImpreciseAmount;
298         }
299         abort();
300 }
301 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
302         switch (val) {
303                 case LDKSemanticError_NoPaymentHash: return 0;
304                 case LDKSemanticError_MultiplePaymentHashes: return 1;
305                 case LDKSemanticError_NoDescription: return 2;
306                 case LDKSemanticError_MultipleDescriptions: return 3;
307                 case LDKSemanticError_NoPaymentSecret: return 4;
308                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
309                 case LDKSemanticError_InvalidFeatures: return 6;
310                 case LDKSemanticError_InvalidRecoveryId: return 7;
311                 case LDKSemanticError_InvalidSignature: return 8;
312                 case LDKSemanticError_ImpreciseAmount: return 9;
313                 default: abort();
314         }
315 }
316 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
317         switch (ord) {
318                 case 0: return LDKSiPrefix_Milli;
319                 case 1: return LDKSiPrefix_Micro;
320                 case 2: return LDKSiPrefix_Nano;
321                 case 3: return LDKSiPrefix_Pico;
322         }
323         abort();
324 }
325 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
326         switch (val) {
327                 case LDKSiPrefix_Milli: return 0;
328                 case LDKSiPrefix_Micro: return 1;
329                 case LDKSiPrefix_Nano: return 2;
330                 case LDKSiPrefix_Pico: return 3;
331                 default: abort();
332         }
333 }
334 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
335         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
336         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
337         return ret;
338 }
339 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray  __attribute__((visibility("default"))) TS_TxOut_get_script_pubkey(uint32_t thing) {
340         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
341         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
342         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
343         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
344         CVec_u8Z_free(ret_var);
345         return ret_arr;
346 }
347
348 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((visibility("default"))) TS_TxOut_get_value(uint32_t thing) {
349         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
350         int64_t ret_val = TxOut_get_value(thing_conv);
351         return ret_val;
352 }
353
354 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_ok(uint32_t arg) {
355         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
356         CHECK(val->result_ok);
357         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
358         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
359         return res_arr;
360 }
361 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeyErrorZ_get_err(uint32_t arg) {
362         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
363         CHECK(!val->result_ok);
364         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
365         return err_conv;
366 }
367 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_ok(uint32_t arg) {
368         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
369         CHECK(val->result_ok);
370         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
371         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
372         return res_arr;
373 }
374 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeyErrorZ_get_err(uint32_t arg) {
375         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
376         CHECK(!val->result_ok);
377         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
378         return err_conv;
379 }
380 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t arg) {
381         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
382         CHECK(val->result_ok);
383         LDKTxCreationKeys res_var = (*val->contents.result);
384         uint64_t res_ref = 0;
385         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
386         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
387         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
388         res_ref = (uint64_t)res_var.inner & ~1;
389         return res_ref;
390 }
391 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t arg) {
392         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
393         CHECK(!val->result_ok);
394         LDKDecodeError err_var = (*val->contents.err);
395         uint64_t err_ref = 0;
396         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
397         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
398         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
399         err_ref = (uint64_t)err_var.inner & ~1;
400         return err_ref;
401 }
402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t arg) {
403         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
404         CHECK(val->result_ok);
405         LDKChannelPublicKeys res_var = (*val->contents.result);
406         uint64_t res_ref = 0;
407         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
408         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
409         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
410         res_ref = (uint64_t)res_var.inner & ~1;
411         return res_ref;
412 }
413 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t arg) {
414         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
415         CHECK(!val->result_ok);
416         LDKDecodeError err_var = (*val->contents.err);
417         uint64_t err_ref = 0;
418         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
419         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
420         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
421         err_ref = (uint64_t)err_var.inner & ~1;
422         return err_ref;
423 }
424 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_ok(uint32_t arg) {
425         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
426         CHECK(val->result_ok);
427         LDKTxCreationKeys res_var = (*val->contents.result);
428         uint64_t res_ref = 0;
429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
431         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
432         res_ref = (uint64_t)res_var.inner & ~1;
433         return res_ref;
434 }
435 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysErrorZ_get_err(uint32_t arg) {
436         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
437         CHECK(!val->result_ok);
438         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
439         return err_conv;
440 }
441 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u32Z_ref_from_ptr(uint32_t ptr) {
442         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
443         switch(obj->tag) {
444                 case LDKCOption_u32Z_Some: {
445                         return 0 /* LDKCOption_u32Z - Some */; (void) obj->some;
446                 }
447                 case LDKCOption_u32Z_None: {
448                         return 0 /* LDKCOption_u32Z - None */;
449                 }
450                 default: abort();
451         }
452 }
453 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t arg) {
454         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
455         CHECK(val->result_ok);
456         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
457         uint64_t res_ref = 0;
458         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
459         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
460         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
461         res_ref = (uint64_t)res_var.inner & ~1;
462         return res_ref;
463 }
464 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t arg) {
465         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
466         CHECK(!val->result_ok);
467         LDKDecodeError err_var = (*val->contents.err);
468         uint64_t err_ref = 0;
469         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
470         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
471         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
472         err_ref = (uint64_t)err_var.inner & ~1;
473         return err_ref;
474 }
475 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
476         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
477         CHECK(val->result_ok);
478         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
479         uint64_t res_ref = 0;
480         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
481         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
482         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
483         res_ref = (uint64_t)res_var.inner & ~1;
484         return res_ref;
485 }
486 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
487         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
488         CHECK(!val->result_ok);
489         LDKDecodeError err_var = (*val->contents.err);
490         uint64_t err_ref = 0;
491         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
492         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
493         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
494         err_ref = (uint64_t)err_var.inner & ~1;
495         return err_ref;
496 }
497 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t arg) {
498         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
499         CHECK(val->result_ok);
500         LDKChannelTransactionParameters res_var = (*val->contents.result);
501         uint64_t res_ref = 0;
502         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
503         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
504         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
505         res_ref = (uint64_t)res_var.inner & ~1;
506         return res_ref;
507 }
508 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t arg) {
509         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
510         CHECK(!val->result_ok);
511         LDKDecodeError err_var = (*val->contents.err);
512         uint64_t err_ref = 0;
513         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
514         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
515         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
516         err_ref = (uint64_t)err_var.inner & ~1;
517         return err_ref;
518 }
519 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
520         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
521         CHECK(val->result_ok);
522         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
523         uint64_t res_ref = 0;
524         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
527         res_ref = (uint64_t)res_var.inner & ~1;
528         return res_ref;
529 }
530 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
531         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
532         CHECK(!val->result_ok);
533         LDKDecodeError err_var = (*val->contents.err);
534         uint64_t err_ref = 0;
535         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
536         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
537         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
538         err_ref = (uint64_t)err_var.inner & ~1;
539         return err_ref;
540 }
541 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
542         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
543         CHECK(val->result_ok);
544         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
545         uint64_t res_ref = 0;
546         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
547         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
548         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
549         res_ref = (uint64_t)res_var.inner & ~1;
550         return res_ref;
551 }
552 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
553         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
554         CHECK(!val->result_ok);
555         LDKDecodeError err_var = (*val->contents.err);
556         uint64_t err_ref = 0;
557         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
558         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
559         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
560         err_ref = (uint64_t)err_var.inner & ~1;
561         return err_ref;
562 }
563 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t arg) {
564         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
565         CHECK(val->result_ok);
566         LDKTrustedClosingTransaction res_var = (*val->contents.result);
567         uint64_t res_ref = 0;
568         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
569         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
570         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
571         res_ref = (uint64_t)res_var.inner & ~1;
572         return res_ref;
573 }
574 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedClosingTransactionNoneZ_get_err(uint32_t arg) {
575         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
576         CHECK(!val->result_ok);
577         return *val->contents.err;
578 }
579 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t arg) {
580         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
581         CHECK(val->result_ok);
582         LDKCommitmentTransaction res_var = (*val->contents.result);
583         uint64_t res_ref = 0;
584         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
585         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
586         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
587         res_ref = (uint64_t)res_var.inner & ~1;
588         return res_ref;
589 }
590 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t arg) {
591         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
592         CHECK(!val->result_ok);
593         LDKDecodeError err_var = (*val->contents.err);
594         uint64_t err_ref = 0;
595         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
596         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
597         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
598         err_ref = (uint64_t)err_var.inner & ~1;
599         return err_ref;
600 }
601 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
602         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
603         CHECK(val->result_ok);
604         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
605         uint64_t res_ref = 0;
606         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
607         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
608         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
609         res_ref = (uint64_t)res_var.inner & ~1;
610         return res_ref;
611 }
612 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
613         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
614         CHECK(!val->result_ok);
615         return *val->contents.err;
616 }
617 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
618         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
619         CHECK(val->result_ok);
620         LDKCVec_SignatureZ res_var = (*val->contents.result);
621         ptrArray res_arr = NULL;
622         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
623         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
624         for (size_t m = 0; m < res_var.datalen; m++) {
625                 int8_tArray res_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
626                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_var.data[m].compact_form, 64);
627                 res_arr_ptr[m] = res_conv_12_arr;
628         }
629         
630         return res_arr;
631 }
632 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
633         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
634         CHECK(!val->result_ok);
635         return *val->contents.err;
636 }
637 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t arg) {
638         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
639         CHECK(val->result_ok);
640         LDKShutdownScript res_var = (*val->contents.result);
641         uint64_t res_ref = 0;
642         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
643         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
644         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
645         res_ref = (uint64_t)res_var.inner & ~1;
646         return res_ref;
647 }
648 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t arg) {
649         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
650         CHECK(!val->result_ok);
651         LDKDecodeError err_var = (*val->contents.err);
652         uint64_t err_ref = 0;
653         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
654         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
655         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
656         err_ref = (uint64_t)err_var.inner & ~1;
657         return err_ref;
658 }
659 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t arg) {
660         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
661         CHECK(val->result_ok);
662         LDKShutdownScript res_var = (*val->contents.result);
663         uint64_t res_ref = 0;
664         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
665         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
666         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
667         res_ref = (uint64_t)res_var.inner & ~1;
668         return res_ref;
669 }
670 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t arg) {
671         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
672         CHECK(!val->result_ok);
673         LDKInvalidShutdownScript err_var = (*val->contents.err);
674         uint64_t err_ref = 0;
675         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
676         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
677         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
678         err_ref = (uint64_t)err_var.inner & ~1;
679         return err_ref;
680 }
681 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_ok(uint32_t arg) {
682         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
683         CHECK(val->result_ok);
684         return *val->contents.result;
685 }
686 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneErrorZ_get_err(uint32_t arg) {
687         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
688         CHECK(!val->result_ok);
689         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
690         return err_conv;
691 }
692 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_ok(uint32_t arg) {
693         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
694         CHECK(val->result_ok);
695         LDKRouteHop res_var = (*val->contents.result);
696         uint64_t res_ref = 0;
697         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
698         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
699         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
700         res_ref = (uint64_t)res_var.inner & ~1;
701         return res_ref;
702 }
703 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHopDecodeErrorZ_get_err(uint32_t arg) {
704         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
705         CHECK(!val->result_ok);
706         LDKDecodeError err_var = (*val->contents.err);
707         uint64_t err_ref = 0;
708         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
709         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
710         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
711         err_ref = (uint64_t)err_var.inner & ~1;
712         return err_ref;
713 }
714 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
715         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
716         for (size_t i = 0; i < ret.datalen; i++) {
717                 ret.data[i] = RouteHop_clone(&orig->data[i]);
718         }
719         return ret;
720 }
721 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
722         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
723         for (size_t i = 0; i < ret.datalen; i++) {
724                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
725         }
726         return ret;
727 }
728 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
729         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
730         CHECK(val->result_ok);
731         LDKRoute res_var = (*val->contents.result);
732         uint64_t res_ref = 0;
733         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
734         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
735         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
736         res_ref = (uint64_t)res_var.inner & ~1;
737         return res_ref;
738 }
739 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
740         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
741         CHECK(!val->result_ok);
742         LDKDecodeError err_var = (*val->contents.err);
743         uint64_t err_ref = 0;
744         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
745         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
746         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
747         err_ref = (uint64_t)err_var.inner & ~1;
748         return err_ref;
749 }
750 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_ok(uint32_t arg) {
751         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
752         CHECK(val->result_ok);
753         LDKRouteParameters res_var = (*val->contents.result);
754         uint64_t res_ref = 0;
755         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
756         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
757         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
758         res_ref = (uint64_t)res_var.inner & ~1;
759         return res_ref;
760 }
761 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteParametersDecodeErrorZ_get_err(uint32_t arg) {
762         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
763         CHECK(!val->result_ok);
764         LDKDecodeError err_var = (*val->contents.err);
765         uint64_t err_ref = 0;
766         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
767         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
768         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
769         err_ref = (uint64_t)err_var.inner & ~1;
770         return err_ref;
771 }
772 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
773         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
774         for (size_t i = 0; i < ret.datalen; i++) {
775                 ret.data[i] = RouteHint_clone(&orig->data[i]);
776         }
777         return ret;
778 }
779 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u64Z_ref_from_ptr(uint32_t ptr) {
780         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
781         switch(obj->tag) {
782                 case LDKCOption_u64Z_Some: {
783                         return 0 /* LDKCOption_u64Z - Some */; (void) obj->some;
784                 }
785                 case LDKCOption_u64Z_None: {
786                         return 0 /* LDKCOption_u64Z - None */;
787                 }
788                 default: abort();
789         }
790 }
791 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_ok(uint32_t arg) {
792         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
793         CHECK(val->result_ok);
794         LDKPayee res_var = (*val->contents.result);
795         uint64_t res_ref = 0;
796         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
797         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
798         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
799         res_ref = (uint64_t)res_var.inner & ~1;
800         return res_ref;
801 }
802 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeeDecodeErrorZ_get_err(uint32_t arg) {
803         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
804         CHECK(!val->result_ok);
805         LDKDecodeError err_var = (*val->contents.err);
806         uint64_t err_ref = 0;
807         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
808         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
809         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
810         err_ref = (uint64_t)err_var.inner & ~1;
811         return err_ref;
812 }
813 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
814         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
815         for (size_t i = 0; i < ret.datalen; i++) {
816                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
817         }
818         return ret;
819 }
820 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_ok(uint32_t arg) {
821         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
822         CHECK(val->result_ok);
823         LDKRouteHint res_var = (*val->contents.result);
824         uint64_t res_ref = 0;
825         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
826         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
827         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
828         res_ref = (uint64_t)res_var.inner & ~1;
829         return res_ref;
830 }
831 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintDecodeErrorZ_get_err(uint32_t arg) {
832         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
833         CHECK(!val->result_ok);
834         LDKDecodeError err_var = (*val->contents.err);
835         uint64_t err_ref = 0;
836         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
837         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
838         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
839         err_ref = (uint64_t)err_var.inner & ~1;
840         return err_ref;
841 }
842 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t arg) {
843         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
844         CHECK(val->result_ok);
845         LDKRouteHintHop res_var = (*val->contents.result);
846         uint64_t res_ref = 0;
847         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
848         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
849         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
850         res_ref = (uint64_t)res_var.inner & ~1;
851         return res_ref;
852 }
853 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteHintHopDecodeErrorZ_get_err(uint32_t arg) {
854         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
855         CHECK(!val->result_ok);
856         LDKDecodeError err_var = (*val->contents.err);
857         uint64_t err_ref = 0;
858         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
859         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
860         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
861         err_ref = (uint64_t)err_var.inner & ~1;
862         return err_ref;
863 }
864 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
865         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
866         for (size_t i = 0; i < ret.datalen; i++) {
867                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
868         }
869         return ret;
870 }
871 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
872         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
873         CHECK(val->result_ok);
874         LDKRoute res_var = (*val->contents.result);
875         uint64_t res_ref = 0;
876         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
877         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
878         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
879         res_ref = (uint64_t)res_var.inner & ~1;
880         return res_ref;
881 }
882 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
883         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
884         CHECK(!val->result_ok);
885         LDKLightningError err_var = (*val->contents.err);
886         uint64_t err_ref = 0;
887         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
888         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
889         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
890         err_ref = (uint64_t)err_var.inner & ~1;
891         return err_ref;
892 }
893 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
894         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
895         CHECK(val->result_ok);
896         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
897         return (uint64_t)res_ref;
898 }
899 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
900         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
901         CHECK(!val->result_ok);
902         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
903         return err_conv;
904 }
905 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
906         return tuple->a;
907 }
908 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t tuple) {
909         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
910         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
911         return ret_val;
912 }
913
914 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
915         return tuple->b;
916 }
917 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t tuple) {
918         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
919         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
920         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
921         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
922         Transaction_free(ret_var);
923         return ret_arr;
924 }
925
926 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
927         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
928         for (size_t i = 0; i < ret.datalen; i++) {
929                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
930         }
931         return ret;
932 }
933 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
934         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
935         for (size_t i = 0; i < ret.datalen; i++) {
936                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
937         }
938         return ret;
939 }
940 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
941         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
942         CHECK(val->result_ok);
943         return *val->contents.result;
944 }
945 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
946         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
947         CHECK(!val->result_ok);
948         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
949         return err_conv;
950 }
951 uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
952         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
953         switch(obj->tag) {
954                 case LDKMonitorEvent_HTLCEvent: {
955                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
956                         uint64_t htlc_event_ref = 0;
957                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
958                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
959                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
960                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
961                         return 0 /* LDKMonitorEvent - HTLCEvent */; (void) htlc_event_ref;
962                 }
963                 case LDKMonitorEvent_CommitmentTxConfirmed: {
964                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
965                         uint64_t commitment_tx_confirmed_ref = 0;
966                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
967                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
968                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
969                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
970                         return 0 /* LDKMonitorEvent - CommitmentTxConfirmed */; (void) commitment_tx_confirmed_ref;
971                 }
972                 case LDKMonitorEvent_UpdateCompleted: {
973                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
974                         uint64_t funding_txo_ref = 0;
975                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
976                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
977                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
978                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
979                         return 0 /* LDKMonitorEvent - UpdateCompleted */; (void) funding_txo_ref; (void) obj->update_completed.monitor_update_id;
980                 }
981                 case LDKMonitorEvent_UpdateFailed: {
982                         LDKOutPoint update_failed_var = obj->update_failed;
983                         uint64_t update_failed_ref = 0;
984                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
985                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
986                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
987                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
988                         return 0 /* LDKMonitorEvent - UpdateFailed */; (void) update_failed_ref;
989                 }
990                 default: abort();
991         }
992 }
993 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
994         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
995         for (size_t i = 0; i < ret.datalen; i++) {
996                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
997         }
998         return ret;
999 }
1000 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ref_from_ptr(uint32_t ptr) {
1001         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1002         switch(obj->tag) {
1003                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1004                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1005                         *some_conv = obj->some;
1006                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1007                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - Some */; (void) ((uint64_t)some_conv);
1008                 }
1009                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1010                         return 0 /* LDKCOption_C2Tuple_usizeTransactionZZ - None */;
1011                 }
1012                 default: abort();
1013         }
1014 }
1015 uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
1016         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1017         switch(obj->tag) {
1018                 case LDKClosureReason_CounterpartyForceClosed: {
1019                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1020                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1021                         return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
1022                 }
1023                 case LDKClosureReason_HolderForceClosed: {
1024                         return 0 /* LDKClosureReason - HolderForceClosed */;
1025                 }
1026                 case LDKClosureReason_CooperativeClosure: {
1027                         return 0 /* LDKClosureReason - CooperativeClosure */;
1028                 }
1029                 case LDKClosureReason_CommitmentTxConfirmed: {
1030                         return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
1031                 }
1032                 case LDKClosureReason_FundingTimedOut: {
1033                         return 0 /* LDKClosureReason - FundingTimedOut */;
1034                 }
1035                 case LDKClosureReason_ProcessingError: {
1036                         LDKStr err_str = obj->processing_error.err;
1037                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1038                         return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
1039                 }
1040                 case LDKClosureReason_DisconnectedPeer: {
1041                         return 0 /* LDKClosureReason - DisconnectedPeer */;
1042                 }
1043                 case LDKClosureReason_OutdatedChannelManager: {
1044                         return 0 /* LDKClosureReason - OutdatedChannelManager */;
1045                 }
1046                 default: abort();
1047         }
1048 }
1049 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_ClosureReasonZ_ref_from_ptr(uint32_t ptr) {
1050         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1051         switch(obj->tag) {
1052                 case LDKCOption_ClosureReasonZ_Some: {
1053                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1054                         return 0 /* LDKCOption_ClosureReasonZ - Some */; (void) some_ref;
1055                 }
1056                 case LDKCOption_ClosureReasonZ_None: {
1057                         return 0 /* LDKCOption_ClosureReasonZ - None */;
1058                 }
1059                 default: abort();
1060         }
1061 }
1062 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t arg) {
1063         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1064         CHECK(val->result_ok);
1065         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1066         return res_ref;
1067 }
1068 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t arg) {
1069         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1070         CHECK(!val->result_ok);
1071         LDKDecodeError err_var = (*val->contents.err);
1072         uint64_t err_ref = 0;
1073         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1074         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1075         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1076         err_ref = (uint64_t)err_var.inner & ~1;
1077         return err_ref;
1078 }
1079 uint32_t __attribute__((visibility("default"))) TS_LDKNetworkUpdate_ref_from_ptr(uint32_t ptr) {
1080         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1081         switch(obj->tag) {
1082                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1083                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1084                         uint64_t msg_ref = 0;
1085                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1086                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1087                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1088                         msg_ref = (uint64_t)msg_var.inner & ~1;
1089                         return 0 /* LDKNetworkUpdate - ChannelUpdateMessage */; (void) msg_ref;
1090                 }
1091                 case LDKNetworkUpdate_ChannelClosed: {
1092                         return 0 /* LDKNetworkUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
1093                 }
1094                 case LDKNetworkUpdate_NodeFailure: {
1095                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1096                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
1097                         return 0 /* LDKNetworkUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
1098                 }
1099                 default: abort();
1100         }
1101 }
1102 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_NetworkUpdateZ_ref_from_ptr(uint32_t ptr) {
1103         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1104         switch(obj->tag) {
1105                 case LDKCOption_NetworkUpdateZ_Some: {
1106                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1107                         return 0 /* LDKCOption_NetworkUpdateZ - Some */; (void) some_ref;
1108                 }
1109                 case LDKCOption_NetworkUpdateZ_None: {
1110                         return 0 /* LDKCOption_NetworkUpdateZ - None */;
1111                 }
1112                 default: abort();
1113         }
1114 }
1115 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
1116         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1117         switch(obj->tag) {
1118                 case LDKSpendableOutputDescriptor_StaticOutput: {
1119                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1120                         uint64_t outpoint_ref = 0;
1121                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1122                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1124                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1125                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1126                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (uint64_t)output_ref;
1127                 }
1128                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1129                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1130                         uint64_t delayed_payment_output_ref = 0;
1131                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1132                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1133                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1134                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1135                         return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */; (void) delayed_payment_output_ref;
1136                 }
1137                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1138                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1139                         uint64_t static_payment_output_ref = 0;
1140                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1141                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1142                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1143                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1144                         return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */; (void) static_payment_output_ref;
1145                 }
1146                 default: abort();
1147         }
1148 }
1149 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1150         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1151         for (size_t i = 0; i < ret.datalen; i++) {
1152                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1153         }
1154         return ret;
1155 }
1156 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
1157         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1158         switch(obj->tag) {
1159                 case LDKPaymentPurpose_InvoicePayment: {
1160                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1161                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
1162                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1163                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
1164                         return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr;
1165                 }
1166                 case LDKPaymentPurpose_SpontaneousPayment: {
1167                         int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1168                         memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
1169                         return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
1170                 }
1171                 default: abort();
1172         }
1173 }
1174 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
1175         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1176         switch(obj->tag) {
1177                 case LDKEvent_FundingGenerationReady: {
1178                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1179                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
1180                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1181                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1182                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
1183                         return 0 /* LDKEvent - FundingGenerationReady */; (void) temporary_channel_id_arr; (void) obj->funding_generation_ready.channel_value_satoshis; (void) output_script_arr; (void) obj->funding_generation_ready.user_channel_id;
1184                 }
1185                 case LDKEvent_PaymentReceived: {
1186                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1187                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
1188                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
1189                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
1190                 }
1191                 case LDKEvent_PaymentSent: {
1192                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1193                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_sent.payment_id.data, 32);
1194                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1195                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
1196                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1197                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
1198                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
1199                         return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
1200                 }
1201                 case LDKEvent_PaymentPathFailed: {
1202                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1203                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_failed.payment_id.data, 32);
1204                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1205                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
1206                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
1207                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1208                         uint32_tArray path_arr = NULL;
1209                         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1210                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
1211                         for (size_t k = 0; k < path_var.datalen; k++) {
1212                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1213                                 uint64_t path_conv_10_ref = 0;
1214                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1215                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1216                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1217                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1218                                 path_arr_ptr[k] = path_conv_10_ref;
1219                         }
1220                         
1221                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
1222                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1223                         uint64_t retry_ref = 0;
1224                         if ((uint64_t)retry_var.inner > 4096) {
1225                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1226                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1227                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1228                                 retry_ref = (uint64_t)retry_var.inner & ~1;
1229                         }
1230                         return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr; (void) short_channel_id_ref; (void) retry_ref;
1231                 }
1232                 case LDKEvent_PaymentFailed: {
1233                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1234                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_failed.payment_id.data, 32);
1235                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1236                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
1237                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_id_arr; (void) payment_hash_arr;
1238                 }
1239                 case LDKEvent_PendingHTLCsForwardable: {
1240                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
1241                 }
1242                 case LDKEvent_SpendableOutputs: {
1243                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1244                         uint32_tArray outputs_arr = NULL;
1245                         outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1246                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
1247                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1248                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
1249                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1250                         }
1251                         
1252                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
1253                 }
1254                 case LDKEvent_PaymentForwarded: {
1255                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1256                         return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
1257                 }
1258                 case LDKEvent_ChannelClosed: {
1259                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1260                         memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
1261                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
1262                         return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) obj->channel_closed.user_channel_id; (void) reason_ref;
1263                 }
1264                 case LDKEvent_DiscardFunding: {
1265                         int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1266                         memcpy((uint8_t*)(channel_id_arr + 4), obj->discard_funding.channel_id.data, 32);
1267                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1268                         int8_tArray transaction_arr = init_arr(transaction_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1269                         memcpy((uint8_t*)(transaction_arr + 4), transaction_var.data, transaction_var.datalen);
1270                         return 0 /* LDKEvent - DiscardFunding */; (void) channel_id_arr; (void) transaction_arr;
1271                 }
1272                 case LDKEvent_PaymentPathSuccessful: {
1273                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1274                         memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_successful.payment_id.data, 32);
1275                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1276                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_successful.payment_hash.data, 32);
1277                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1278                         uint32_tArray path_arr = NULL;
1279                         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1280                         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
1281                         for (size_t k = 0; k < path_var.datalen; k++) {
1282                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1283                                 uint64_t path_conv_10_ref = 0;
1284                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1285                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1286                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1287                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1288                                 path_arr_ptr[k] = path_conv_10_ref;
1289                         }
1290                         
1291                         return 0 /* LDKEvent - PaymentPathSuccessful */; (void) payment_id_arr; (void) payment_hash_arr; (void) path_arr;
1292                 }
1293                 default: abort();
1294         }
1295 }
1296 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_EventZ_ref_from_ptr(uint32_t ptr) {
1297         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1298         switch(obj->tag) {
1299                 case LDKCOption_EventZ_Some: {
1300                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1301                         return 0 /* LDKCOption_EventZ - Some */; (void) some_ref;
1302                 }
1303                 case LDKCOption_EventZ_None: {
1304                         return 0 /* LDKCOption_EventZ - None */;
1305                 }
1306                 default: abort();
1307         }
1308 }
1309 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_EventZDecodeErrorZ_get_ok(uint32_t arg) {
1310         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1311         CHECK(val->result_ok);
1312         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1313         return res_ref;
1314 }
1315 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_EventZDecodeErrorZ_get_err(uint32_t arg) {
1316         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1317         CHECK(!val->result_ok);
1318         LDKDecodeError err_var = (*val->contents.err);
1319         uint64_t err_ref = 0;
1320         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1321         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1322         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1323         err_ref = (uint64_t)err_var.inner & ~1;
1324         return err_ref;
1325 }
1326 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
1327         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1328         switch(obj->tag) {
1329                 case LDKErrorAction_DisconnectPeer: {
1330                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1331                         uint64_t msg_ref = 0;
1332                         if ((uint64_t)msg_var.inner > 4096) {
1333                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1334                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1335                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1336                                 msg_ref = (uint64_t)msg_var.inner & ~1;
1337                         }
1338                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
1339                 }
1340                 case LDKErrorAction_IgnoreError: {
1341                         return 0 /* LDKErrorAction - IgnoreError */;
1342                 }
1343                 case LDKErrorAction_IgnoreAndLog: {
1344                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1345                         return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
1346                 }
1347                 case LDKErrorAction_IgnoreDuplicateGossip: {
1348                         return 0 /* LDKErrorAction - IgnoreDuplicateGossip */;
1349                 }
1350                 case LDKErrorAction_SendErrorMessage: {
1351                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1352                         uint64_t msg_ref = 0;
1353                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1354                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1355                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1356                         msg_ref = (uint64_t)msg_var.inner & ~1;
1357                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
1358                 }
1359                 default: abort();
1360         }
1361 }
1362 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
1363         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1364         switch(obj->tag) {
1365                 case LDKMessageSendEvent_SendAcceptChannel: {
1366                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1367                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
1368                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
1369                         uint64_t msg_ref = 0;
1370                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1371                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1372                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1373                         msg_ref = (uint64_t)msg_var.inner & ~1;
1374                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
1375                 }
1376                 case LDKMessageSendEvent_SendOpenChannel: {
1377                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1378                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
1379                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
1380                         uint64_t msg_ref = 0;
1381                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1382                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1383                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1384                         msg_ref = (uint64_t)msg_var.inner & ~1;
1385                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
1386                 }
1387                 case LDKMessageSendEvent_SendFundingCreated: {
1388                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1389                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
1390                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
1391                         uint64_t msg_ref = 0;
1392                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1393                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1394                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1395                         msg_ref = (uint64_t)msg_var.inner & ~1;
1396                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
1397                 }
1398                 case LDKMessageSendEvent_SendFundingSigned: {
1399                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1400                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
1401                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
1402                         uint64_t msg_ref = 0;
1403                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1404                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1405                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1406                         msg_ref = (uint64_t)msg_var.inner & ~1;
1407                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
1408                 }
1409                 case LDKMessageSendEvent_SendFundingLocked: {
1410                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1411                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
1412                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
1413                         uint64_t msg_ref = 0;
1414                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1415                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1416                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1417                         msg_ref = (uint64_t)msg_var.inner & ~1;
1418                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
1419                 }
1420                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
1421                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1422                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
1423                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
1424                         uint64_t msg_ref = 0;
1425                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1426                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1427                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1428                         msg_ref = (uint64_t)msg_var.inner & ~1;
1429                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
1430                 }
1431                 case LDKMessageSendEvent_UpdateHTLCs: {
1432                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1433                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
1434                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
1435                         uint64_t updates_ref = 0;
1436                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
1439                         updates_ref = (uint64_t)updates_var.inner & ~1;
1440                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
1441                 }
1442                 case LDKMessageSendEvent_SendRevokeAndACK: {
1443                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1444                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
1445                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
1446                         uint64_t msg_ref = 0;
1447                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1448                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1449                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1450                         msg_ref = (uint64_t)msg_var.inner & ~1;
1451                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
1452                 }
1453                 case LDKMessageSendEvent_SendClosingSigned: {
1454                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1455                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
1456                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
1457                         uint64_t msg_ref = 0;
1458                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1459                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1460                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1461                         msg_ref = (uint64_t)msg_var.inner & ~1;
1462                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
1463                 }
1464                 case LDKMessageSendEvent_SendShutdown: {
1465                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1466                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
1467                         LDKShutdown msg_var = obj->send_shutdown.msg;
1468                         uint64_t msg_ref = 0;
1469                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1470                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1471                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1472                         msg_ref = (uint64_t)msg_var.inner & ~1;
1473                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
1474                 }
1475                 case LDKMessageSendEvent_SendChannelReestablish: {
1476                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1477                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
1478                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
1479                         uint64_t msg_ref = 0;
1480                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1481                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1482                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1483                         msg_ref = (uint64_t)msg_var.inner & ~1;
1484                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
1485                 }
1486                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
1487                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
1488                         uint64_t msg_ref = 0;
1489                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1490                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1491                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1492                         msg_ref = (uint64_t)msg_var.inner & ~1;
1493                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
1494                         uint64_t update_msg_ref = 0;
1495                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1496                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1497                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
1498                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
1499                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
1500                 }
1501                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
1502                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
1503                         uint64_t msg_ref = 0;
1504                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1505                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1506                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1507                         msg_ref = (uint64_t)msg_var.inner & ~1;
1508                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
1509                 }
1510                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
1511                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
1512                         uint64_t msg_ref = 0;
1513                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1514                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1515                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1516                         msg_ref = (uint64_t)msg_var.inner & ~1;
1517                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
1518                 }
1519                 case LDKMessageSendEvent_SendChannelUpdate: {
1520                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1521                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
1522                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
1523                         uint64_t msg_ref = 0;
1524                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1525                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1526                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1527                         msg_ref = (uint64_t)msg_var.inner & ~1;
1528                         return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
1529                 }
1530                 case LDKMessageSendEvent_HandleError: {
1531                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1532                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
1533                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
1534                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
1535                 }
1536                 case LDKMessageSendEvent_SendChannelRangeQuery: {
1537                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1538                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
1539                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
1540                         uint64_t msg_ref = 0;
1541                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1542                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1543                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1544                         msg_ref = (uint64_t)msg_var.inner & ~1;
1545                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
1546                 }
1547                 case LDKMessageSendEvent_SendShortIdsQuery: {
1548                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1549                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
1550                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
1551                         uint64_t msg_ref = 0;
1552                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1553                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1554                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1555                         msg_ref = (uint64_t)msg_var.inner & ~1;
1556                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
1557                 }
1558                 case LDKMessageSendEvent_SendReplyChannelRange: {
1559                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1560                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
1561                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
1562                         uint64_t msg_ref = 0;
1563                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1564                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1565                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1566                         msg_ref = (uint64_t)msg_var.inner & ~1;
1567                         return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
1568                 }
1569                 default: abort();
1570         }
1571 }
1572 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
1573         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
1574         for (size_t i = 0; i < ret.datalen; i++) {
1575                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
1576         }
1577         return ret;
1578 }
1579 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t arg) {
1580         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
1581         CHECK(val->result_ok);
1582         LDKScoringParameters res_var = (*val->contents.result);
1583         uint64_t res_ref = 0;
1584         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1585         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1586         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1587         res_ref = (uint64_t)res_var.inner & ~1;
1588         return res_ref;
1589 }
1590 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_err(uint32_t arg) {
1591         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
1592         CHECK(!val->result_ok);
1593         LDKDecodeError err_var = (*val->contents.err);
1594         uint64_t err_ref = 0;
1595         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1596         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1597         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1598         err_ref = (uint64_t)err_var.inner & ~1;
1599         return err_ref;
1600 }
1601 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_ok(uint32_t arg) {
1602         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
1603         CHECK(val->result_ok);
1604         LDKScorer res_var = (*val->contents.result);
1605         uint64_t res_ref = 0;
1606         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1607         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1608         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1609         res_ref = (uint64_t)res_var.inner & ~1;
1610         return res_ref;
1611 }
1612 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_err(uint32_t arg) {
1613         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
1614         CHECK(!val->result_ok);
1615         LDKDecodeError err_var = (*val->contents.err);
1616         uint64_t err_ref = 0;
1617         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1618         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1619         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1620         err_ref = (uint64_t)err_var.inner & ~1;
1621         return err_ref;
1622 }
1623 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1624         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1625         CHECK(val->result_ok);
1626         LDKInitFeatures res_var = (*val->contents.result);
1627         uint64_t res_ref = 0;
1628         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1629         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1630         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1631         res_ref = (uint64_t)res_var.inner & ~1;
1632         return res_ref;
1633 }
1634 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1635         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
1636         CHECK(!val->result_ok);
1637         LDKDecodeError err_var = (*val->contents.err);
1638         uint64_t err_ref = 0;
1639         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1640         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1641         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1642         err_ref = (uint64_t)err_var.inner & ~1;
1643         return err_ref;
1644 }
1645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1646         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1647         CHECK(val->result_ok);
1648         LDKChannelFeatures res_var = (*val->contents.result);
1649         uint64_t res_ref = 0;
1650         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1651         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1652         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1653         res_ref = (uint64_t)res_var.inner & ~1;
1654         return res_ref;
1655 }
1656 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1657         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
1658         CHECK(!val->result_ok);
1659         LDKDecodeError err_var = (*val->contents.err);
1660         uint64_t err_ref = 0;
1661         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1662         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1663         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1664         err_ref = (uint64_t)err_var.inner & ~1;
1665         return err_ref;
1666 }
1667 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1668         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1669         CHECK(val->result_ok);
1670         LDKNodeFeatures res_var = (*val->contents.result);
1671         uint64_t res_ref = 0;
1672         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1673         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1674         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1675         res_ref = (uint64_t)res_var.inner & ~1;
1676         return res_ref;
1677 }
1678 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1679         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
1680         CHECK(!val->result_ok);
1681         LDKDecodeError err_var = (*val->contents.err);
1682         uint64_t err_ref = 0;
1683         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1684         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1685         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1686         err_ref = (uint64_t)err_var.inner & ~1;
1687         return err_ref;
1688 }
1689 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1690         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1691         CHECK(val->result_ok);
1692         LDKInvoiceFeatures res_var = (*val->contents.result);
1693         uint64_t res_ref = 0;
1694         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1695         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1696         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1697         res_ref = (uint64_t)res_var.inner & ~1;
1698         return res_ref;
1699 }
1700 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1701         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
1702         CHECK(!val->result_ok);
1703         LDKDecodeError err_var = (*val->contents.err);
1704         uint64_t err_ref = 0;
1705         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1706         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1707         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1708         err_ref = (uint64_t)err_var.inner & ~1;
1709         return err_ref;
1710 }
1711 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
1712         LDKCResult_ChannelTypeFeaturesDecodeErrorZ *val = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
1713         CHECK(val->result_ok);
1714         LDKChannelTypeFeatures res_var = (*val->contents.result);
1715         uint64_t res_ref = 0;
1716         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1717         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1718         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1719         res_ref = (uint64_t)res_var.inner & ~1;
1720         return res_ref;
1721 }
1722 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
1723         LDKCResult_ChannelTypeFeaturesDecodeErrorZ *val = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
1724         CHECK(!val->result_ok);
1725         LDKDecodeError err_var = (*val->contents.err);
1726         uint64_t err_ref = 0;
1727         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1728         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1729         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1730         err_ref = (uint64_t)err_var.inner & ~1;
1731         return err_ref;
1732 }
1733 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1734         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1735         CHECK(val->result_ok);
1736         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
1737         uint64_t res_ref = 0;
1738         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1739         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1740         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1741         res_ref = (uint64_t)res_var.inner & ~1;
1742         return res_ref;
1743 }
1744 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1745         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1746         CHECK(!val->result_ok);
1747         LDKDecodeError err_var = (*val->contents.err);
1748         uint64_t err_ref = 0;
1749         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1750         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1751         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1752         err_ref = (uint64_t)err_var.inner & ~1;
1753         return err_ref;
1754 }
1755 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1756         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1757         CHECK(val->result_ok);
1758         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
1759         uint64_t res_ref = 0;
1760         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1761         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1762         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1763         res_ref = (uint64_t)res_var.inner & ~1;
1764         return res_ref;
1765 }
1766 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1767         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
1768         CHECK(!val->result_ok);
1769         LDKDecodeError err_var = (*val->contents.err);
1770         uint64_t err_ref = 0;
1771         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1772         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1773         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1774         err_ref = (uint64_t)err_var.inner & ~1;
1775         return err_ref;
1776 }
1777 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1778         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1779         CHECK(val->result_ok);
1780         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1781         return res_ref;
1782 }
1783 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1784         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1785         CHECK(!val->result_ok);
1786         LDKDecodeError err_var = (*val->contents.err);
1787         uint64_t err_ref = 0;
1788         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1789         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1790         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1791         err_ref = (uint64_t)err_var.inner & ~1;
1792         return err_ref;
1793 }
1794 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) {
1795         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1796         CHECK(val->result_ok);
1797         return *val->contents.result;
1798 }
1799 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) {
1800         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
1801         CHECK(!val->result_ok);
1802         return *val->contents.err;
1803 }
1804 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1805         return tuple->a;
1806 }
1807 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t tuple) {
1808         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1809         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1810         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form, 64);
1811         return ret_arr;
1812 }
1813
1814 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
1815         return tuple->b;
1816 }
1817 ptrArray  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
1818         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
1819         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
1820         ptrArray ret_arr = NULL;
1821         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
1822         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
1823         for (size_t m = 0; m < ret_var.datalen; m++) {
1824                 int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1825                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
1826                 ret_arr_ptr[m] = ret_conv_12_arr;
1827         }
1828         
1829         FREE(ret_var.data);
1830         return ret_arr;
1831 }
1832
1833 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
1834         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1835         CHECK(val->result_ok);
1836         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1837         *res_conv = (*val->contents.result);
1838         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
1839         return ((uint64_t)res_conv);
1840 }
1841 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
1842         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
1843         CHECK(!val->result_ok);
1844         return *val->contents.err;
1845 }
1846 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
1847         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1848         CHECK(val->result_ok);
1849         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
1850         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
1851         return res_arr;
1852 }
1853 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
1854         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
1855         CHECK(!val->result_ok);
1856         return *val->contents.err;
1857 }
1858 typedef struct LDKBaseSign_JCalls {
1859         atomic_size_t refcnt;
1860         uint32_t get_per_commitment_point_meth;
1861         uint32_t release_commitment_secret_meth;
1862         uint32_t validate_holder_commitment_meth;
1863         uint32_t channel_keys_id_meth;
1864         uint32_t sign_counterparty_commitment_meth;
1865         uint32_t validate_counterparty_revocation_meth;
1866         uint32_t sign_holder_commitment_and_htlcs_meth;
1867         uint32_t sign_justice_revoked_output_meth;
1868         uint32_t sign_justice_revoked_htlc_meth;
1869         uint32_t sign_counterparty_htlc_transaction_meth;
1870         uint32_t sign_closing_transaction_meth;
1871         uint32_t sign_channel_announcement_meth;
1872         uint32_t ready_channel_meth;
1873 } LDKBaseSign_JCalls;
1874 static void LDKBaseSign_JCalls_free(void* this_arg) {
1875         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1876         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1877                 js_free(j_calls->get_per_commitment_point_meth);
1878                 js_free(j_calls->release_commitment_secret_meth);
1879                 js_free(j_calls->validate_holder_commitment_meth);
1880                 js_free(j_calls->channel_keys_id_meth);
1881                 js_free(j_calls->sign_counterparty_commitment_meth);
1882                 js_free(j_calls->validate_counterparty_revocation_meth);
1883                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
1884                 js_free(j_calls->sign_justice_revoked_output_meth);
1885                 js_free(j_calls->sign_justice_revoked_htlc_meth);
1886                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1887                 js_free(j_calls->sign_closing_transaction_meth);
1888                 js_free(j_calls->sign_channel_announcement_meth);
1889                 js_free(j_calls->ready_channel_meth);
1890                 FREE(j_calls);
1891         }
1892 }
1893 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1894         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1895         int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1896         LDKPublicKey ret_ref;
1897         CHECK(*((uint32_t*)ret) == 33);
1898         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
1899         return ret_ref;
1900 }
1901 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1902         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1903         int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1904         LDKThirtyTwoBytes ret_ref;
1905         CHECK(*((uint32_t*)ret) == 32);
1906         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1907         return ret_ref;
1908 }
1909 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1910         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1911         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1912         uint64_t holder_tx_ref = 0;
1913         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1914         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1915         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1916         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1917         holder_tx_ref = (uint64_t)holder_tx_var.inner;
1918         if (holder_tx_var.is_owned) {
1919                 holder_tx_ref |= 1;
1920         }
1921         uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref);
1922         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1923         CHECK_ACCESS(ret_ptr);
1924         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1925         FREE((void*)ret);
1926         return ret_conv;
1927 }
1928 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1929         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1930         int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
1931         LDKThirtyTwoBytes ret_ref;
1932         CHECK(*((uint32_t*)ret) == 32);
1933         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
1934         return ret_ref;
1935 }
1936 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1937         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1938         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1939         uint64_t commitment_tx_ref = 0;
1940         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1941         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1942         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1943         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1944         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1945         if (commitment_tx_var.is_owned) {
1946                 commitment_tx_ref |= 1;
1947         }
1948         uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1949         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1950         CHECK_ACCESS(ret_ptr);
1951         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1952         FREE((void*)ret);
1953         return ret_conv;
1954 }
1955 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
1956         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1957         int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1958         memcpy((uint8_t*)(secret_arr + 4), *secret, 32);
1959         uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
1960         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1961         CHECK_ACCESS(ret_ptr);
1962         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1963         FREE((void*)ret);
1964         return ret_conv;
1965 }
1966 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1967         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1968         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1969         uint64_t commitment_tx_ref = 0;
1970         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1971         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1972         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1973         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1974         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
1975         if (commitment_tx_var.is_owned) {
1976                 commitment_tx_ref |= 1;
1977         }
1978         uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
1979         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1980         CHECK_ACCESS(ret_ptr);
1981         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
1982         FREE((void*)ret);
1983         return ret_conv;
1984 }
1985 LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
1986         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1987         LDKTransaction justice_tx_var = justice_tx;
1988         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1989         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1990         Transaction_free(justice_tx_var);
1991         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1992         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1993         uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
1994         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
1995         CHECK_ACCESS(ret_ptr);
1996         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
1997         FREE((void*)ret);
1998         return ret_conv;
1999 }
2000 LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
2001         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2002         LDKTransaction justice_tx_var = justice_tx;
2003         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2004         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
2005         Transaction_free(justice_tx_var);
2006         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2007         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
2008         LDKHTLCOutputInCommitment htlc_var = *htlc;
2009         uint64_t htlc_ref = 0;
2010         htlc_var = HTLCOutputInCommitment_clone(htlc);
2011         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2012         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2013         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2014         htlc_ref = (uint64_t)htlc_var.inner;
2015         if (htlc_var.is_owned) {
2016                 htlc_ref |= 1;
2017         }
2018         uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2019         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2020         CHECK_ACCESS(ret_ptr);
2021         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2022         FREE((void*)ret);
2023         return ret_conv;
2024 }
2025 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
2026         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2027         LDKTransaction htlc_tx_var = htlc_tx;
2028         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2029         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
2030         Transaction_free(htlc_tx_var);
2031         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2032         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
2033         LDKHTLCOutputInCommitment htlc_var = *htlc;
2034         uint64_t htlc_ref = 0;
2035         htlc_var = HTLCOutputInCommitment_clone(htlc);
2036         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2037         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2038         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2039         htlc_ref = (uint64_t)htlc_var.inner;
2040         if (htlc_var.is_owned) {
2041                 htlc_ref |= 1;
2042         }
2043         uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
2044         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2045         CHECK_ACCESS(ret_ptr);
2046         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2047         FREE((void*)ret);
2048         return ret_conv;
2049 }
2050 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2051         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2052         LDKClosingTransaction closing_tx_var = *closing_tx;
2053         uint64_t closing_tx_ref = 0;
2054         closing_tx_var = ClosingTransaction_clone(closing_tx);
2055         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2056         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2057         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
2058         closing_tx_ref = (uint64_t)closing_tx_var.inner;
2059         if (closing_tx_var.is_owned) {
2060                 closing_tx_ref |= 1;
2061         }
2062         uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref);
2063         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2064         CHECK_ACCESS(ret_ptr);
2065         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2066         FREE((void*)ret);
2067         return ret_conv;
2068 }
2069 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2070         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2071         LDKUnsignedChannelAnnouncement msg_var = *msg;
2072         uint64_t msg_ref = 0;
2073         msg_var = UnsignedChannelAnnouncement_clone(msg);
2074         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2075         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2076         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2077         msg_ref = (uint64_t)msg_var.inner;
2078         if (msg_var.is_owned) {
2079                 msg_ref |= 1;
2080         }
2081         uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
2082         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2083         CHECK_ACCESS(ret_ptr);
2084         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2085         FREE((void*)ret);
2086         return ret_conv;
2087 }
2088 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2089         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2090         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2091         uint64_t channel_parameters_ref = 0;
2092         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2093         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2094         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2095         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
2096         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
2097         if (channel_parameters_var.is_owned) {
2098                 channel_parameters_ref |= 1;
2099         }
2100         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
2101 }
2102 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
2103         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
2104         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2105 }
2106 static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
2107         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2108         atomic_init(&calls->refcnt, 1);
2109         //TODO: Assign calls->o from o
2110
2111         LDKChannelPublicKeys pubkeys_conv;
2112         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2113         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2114         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2115
2116         LDKBaseSign ret = {
2117                 .this_arg = (void*) calls,
2118                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2119                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2120                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2121                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2122                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2123                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2124                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2125                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2126                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2127                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2128                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2129                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2130                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2131                 .free = LDKBaseSign_JCalls_free,
2132                 .pubkeys = pubkeys_conv,
2133                 .set_pubkeys = NULL,
2134         };
2135         return ret;
2136 }
2137 long  __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
2138         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2139         *res_ptr = LDKBaseSign_init(o, pubkeys);
2140         return (long)res_ptr;
2141 }
2142 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2143         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2145         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2146         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2147         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2148         return ret_arr;
2149 }
2150
2151 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2152         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2153         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2154         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2155         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2156         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2157         return ret_arr;
2158 }
2159
2160 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
2161         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2162         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2163         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2164         LDKHolderCommitmentTransaction holder_tx_conv;
2165         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2166         holder_tx_conv.is_owned = false;
2167         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
2168         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2169         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2170         return (uint64_t)ret_conv;
2171 }
2172
2173 int8_tArray  __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
2174         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2175         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2176         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2177         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2178         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2179         return ret_arr;
2180 }
2181
2182 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2183         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2185         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2186         LDKCommitmentTransaction commitment_tx_conv;
2187         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2188         commitment_tx_conv.is_owned = false;
2189         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2190         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2191         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2192         return (uint64_t)ret_conv;
2193 }
2194
2195 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
2196         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2198         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2199         unsigned char secret_arr[32];
2200         CHECK(*((uint32_t*)secret) == 32);
2201         memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
2202         unsigned char (*secret_ref)[32] = &secret_arr;
2203         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2204         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2205         return (uint64_t)ret_conv;
2206 }
2207
2208 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
2209         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2210         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2211         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2212         LDKHolderCommitmentTransaction commitment_tx_conv;
2213         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2214         commitment_tx_conv.is_owned = false;
2215         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2216         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2217         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2218         return (uint64_t)ret_conv;
2219 }
2220
2221 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
2222         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2224         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2225         LDKTransaction justice_tx_ref;
2226         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2227         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2228         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2229         justice_tx_ref.data_is_owned = true;
2230         unsigned char per_commitment_key_arr[32];
2231         CHECK(*((uint32_t*)per_commitment_key) == 32);
2232         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2233         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2234         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2235         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2236         return (uint64_t)ret_conv;
2237 }
2238
2239 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
2240         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2241         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2242         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2243         LDKTransaction justice_tx_ref;
2244         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
2245         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2246         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
2247         justice_tx_ref.data_is_owned = true;
2248         unsigned char per_commitment_key_arr[32];
2249         CHECK(*((uint32_t*)per_commitment_key) == 32);
2250         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
2251         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2252         LDKHTLCOutputInCommitment htlc_conv;
2253         htlc_conv.inner = (void*)(htlc & (~1));
2254         htlc_conv.is_owned = false;
2255         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2256         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2257         *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
2258         return (uint64_t)ret_conv;
2259 }
2260
2261 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
2262         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2265         LDKTransaction htlc_tx_ref;
2266         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
2267         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2268         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
2269         htlc_tx_ref.data_is_owned = true;
2270         LDKPublicKey per_commitment_point_ref;
2271         CHECK(*((uint32_t*)per_commitment_point) == 33);
2272         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
2273         LDKHTLCOutputInCommitment htlc_conv;
2274         htlc_conv.inner = (void*)(htlc & (~1));
2275         htlc_conv.is_owned = false;
2276         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2277         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2278         *ret_conv = (this_arg_conv->sign_counterparty_htlc_transaction)(this_arg_conv->this_arg, htlc_tx_ref, input, amount, per_commitment_point_ref, &htlc_conv);
2279         return (uint64_t)ret_conv;
2280 }
2281
2282 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
2283         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2284         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2285         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2286         LDKClosingTransaction closing_tx_conv;
2287         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2288         closing_tx_conv.is_owned = false;
2289         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2290         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2291         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2292         return (uint64_t)ret_conv;
2293 }
2294
2295 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2296         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2297         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2298         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2299         LDKUnsignedChannelAnnouncement msg_conv;
2300         msg_conv.inner = (void*)(msg & (~1));
2301         msg_conv.is_owned = false;
2302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2303         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2304         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2305         return (uint64_t)ret_conv;
2306 }
2307
2308 void  __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2309         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2311         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2312         LDKChannelTransactionParameters channel_parameters_conv;
2313         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2314         channel_parameters_conv.is_owned = false;
2315         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
2316         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2317 }
2318
2319 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2320         if (this_arg->set_pubkeys != NULL)
2321                 this_arg->set_pubkeys(this_arg);
2322         return this_arg->pubkeys;
2323 }
2324 uint32_t  __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
2325         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2326         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2327         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2328         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2329         uint64_t ret_ref = 0;
2330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2333         ret_ref = (uint64_t)ret_var.inner;
2334         if (ret_var.is_owned) {
2335                 ret_ref |= 1;
2336         }
2337         return ret_ref;
2338 }
2339
2340 typedef struct LDKSign_JCalls {
2341         atomic_size_t refcnt;
2342         LDKBaseSign_JCalls* BaseSign;
2343         uint32_t write_meth;
2344 } LDKSign_JCalls;
2345 static void LDKSign_JCalls_free(void* this_arg) {
2346         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2347         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2348                 js_free(j_calls->write_meth);
2349                 FREE(j_calls);
2350         }
2351 }
2352 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2353         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2354         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
2355         LDKCVec_u8Z ret_ref;
2356         ret_ref.datalen = *((uint32_t*)ret);
2357         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2358         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
2359         return ret_ref;
2360 }
2361 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2362         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2363         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2364         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2365 }
2366 static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
2367         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2368         atomic_init(&calls->refcnt, 1);
2369         //TODO: Assign calls->o from o
2370
2371         LDKChannelPublicKeys pubkeys_conv;
2372         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2373         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2374         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2375
2376         LDKSign ret = {
2377                 .this_arg = (void*) calls,
2378                 .write = write_LDKSign_jcall,
2379                 .cloned = LDKSign_JCalls_cloned,
2380                 .free = LDKSign_JCalls_free,
2381                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
2382         };
2383         calls->BaseSign = ret.BaseSign.this_arg;
2384         return ret;
2385 }
2386 long  __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
2387         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2388         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2389         return (long)res_ptr;
2390 }
2391 int8_tArray  __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
2392         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
2393         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2394         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
2395         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2396         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2397         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
2398         CVec_u8Z_free(ret_var);
2399         return ret_arr;
2400 }
2401
2402 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
2403         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2404         CHECK(val->result_ok);
2405         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
2406         *res_ret = Sign_clone(&(*val->contents.result));
2407         return (uint64_t)res_ret;
2408 }
2409 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
2410         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
2411         CHECK(!val->result_ok);
2412         LDKDecodeError err_var = (*val->contents.err);
2413         uint64_t err_ref = 0;
2414         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2415         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2416         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2417         err_ref = (uint64_t)err_var.inner & ~1;
2418         return err_ref;
2419 }
2420 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
2421         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2422         CHECK(val->result_ok);
2423         int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
2424         memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
2425         return es_arr;
2426 }
2427 void  __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
2428         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
2429         CHECK(!val->result_ok);
2430         return *val->contents.err;
2431 }
2432 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
2433         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
2434         for (size_t i = 0; i < ret.datalen; i++) {
2435                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
2436         }
2437         return ret;
2438 }
2439 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
2440         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2441         CHECK(val->result_ok);
2442         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
2443         ptrArray res_arr = NULL;
2444         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2445         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2446         for (size_t m = 0; m < res_var.datalen; m++) {
2447                 LDKCVec_u8Z res_conv_12_var = res_var.data[m];
2448                 int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2449                 memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
2450                 res_arr_ptr[m] = res_conv_12_arr;
2451         }
2452         
2453         return res_arr;
2454 }
2455 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
2456         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
2457         CHECK(!val->result_ok);
2458         return *val->contents.err;
2459 }
2460 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
2461         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2462         CHECK(val->result_ok);
2463         LDKInMemorySigner res_var = (*val->contents.result);
2464         uint64_t res_ref = 0;
2465         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2466         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2467         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2468         res_ref = (uint64_t)res_var.inner & ~1;
2469         return res_ref;
2470 }
2471 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
2472         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
2473         CHECK(!val->result_ok);
2474         LDKDecodeError err_var = (*val->contents.err);
2475         uint64_t err_ref = 0;
2476         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2477         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2478         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2479         err_ref = (uint64_t)err_var.inner & ~1;
2480         return err_ref;
2481 }
2482 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
2483         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
2484         for (size_t i = 0; i < ret.datalen; i++) {
2485                 ret.data[i] = TxOut_clone(&orig->data[i]);
2486         }
2487         return ret;
2488 }
2489 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
2490         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2491         CHECK(val->result_ok);
2492         LDKTransaction res_var = (*val->contents.result);
2493         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2494         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2495         return res_arr;
2496 }
2497 void  __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
2498         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
2499         CHECK(!val->result_ok);
2500         return *val->contents.err;
2501 }
2502 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2503         return ThirtyTwoBytes_clone(&tuple->a);
2504 }
2505 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t tuple) {
2506         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2507         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2508         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data, 32);
2509         return ret_arr;
2510 }
2511
2512 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
2513         return ChannelMonitor_clone(&tuple->b);
2514 }
2515 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
2516         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
2517         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
2518         uint64_t ret_ref = 0;
2519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2522         ret_ref = (uint64_t)ret_var.inner;
2523         if (ret_var.is_owned) {
2524                 ret_ref |= 1;
2525         }
2526         return ret_ref;
2527 }
2528
2529 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
2530         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
2531         for (size_t i = 0; i < ret.datalen; i++) {
2532                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
2533         }
2534         return ret;
2535 }
2536 uint32_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
2537         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2538         CHECK(val->result_ok);
2539         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
2540         uint32_tArray res_arr = NULL;
2541         res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2542         uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
2543         for (size_t j = 0; j < res_var.datalen; j++) {
2544                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2545                 *res_conv_35_conv = res_var.data[j];
2546                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
2547                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
2548         }
2549         
2550         return res_arr;
2551 }
2552 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
2553         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
2554         CHECK(!val->result_ok);
2555         uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
2556         return err_conv;
2557 }
2558 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
2559         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
2560         switch(obj->tag) {
2561                 case LDKCOption_u16Z_Some: {
2562                         return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
2563                 }
2564                 case LDKCOption_u16Z_None: {
2565                         return 0 /* LDKCOption_u16Z - None */;
2566                 }
2567                 default: abort();
2568         }
2569 }
2570 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
2571         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
2572         switch(obj->tag) {
2573                 case LDKAPIError_APIMisuseError: {
2574                         LDKStr err_str = obj->api_misuse_error.err;
2575                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2576                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
2577                 }
2578                 case LDKAPIError_FeeRateTooHigh: {
2579                         LDKStr err_str = obj->fee_rate_too_high.err;
2580                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2581                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
2582                 }
2583                 case LDKAPIError_RouteError: {
2584                         LDKStr err_str = obj->route_error.err;
2585                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2586                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
2587                 }
2588                 case LDKAPIError_ChannelUnavailable: {
2589                         LDKStr err_str = obj->channel_unavailable.err;
2590                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
2591                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
2592                 }
2593                 case LDKAPIError_MonitorUpdateFailed: {
2594                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
2595                 }
2596                 case LDKAPIError_IncompatibleShutdownScript: {
2597                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
2598                         uint64_t script_ref = 0;
2599                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2600                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2601                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
2602                         script_ref = (uint64_t)script_var.inner & ~1;
2603                         return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
2604                 }
2605                 default: abort();
2606         }
2607 }
2608 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
2609         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2610         CHECK(val->result_ok);
2611         return *val->contents.result;
2612 }
2613 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
2614         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
2615         CHECK(!val->result_ok);
2616         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2617         return err_ref;
2618 }
2619 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
2620         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
2621         for (size_t i = 0; i < ret.datalen; i++) {
2622                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
2623         }
2624         return ret;
2625 }
2626 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
2627         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
2628         for (size_t i = 0; i < ret.datalen; i++) {
2629                 ret.data[i] = APIError_clone(&orig->data[i]);
2630         }
2631         return ret;
2632 }
2633 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_ok(uint32_t arg) {
2634         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2635         CHECK(val->result_ok);
2636         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2637         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2638         return res_arr;
2639 }
2640 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_err(uint32_t arg) {
2641         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
2642         CHECK(!val->result_ok);
2643         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2644         return err_ref;
2645 }
2646 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
2647         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
2648         switch(obj->tag) {
2649                 case LDKPaymentSendFailure_ParameterError: {
2650                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
2651                         return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
2652                 }
2653                 case LDKPaymentSendFailure_PathParameterError: {
2654                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
2655                         uint32_tArray path_parameter_error_arr = NULL;
2656                         path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2657                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
2658                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
2659                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2660                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
2661                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
2662                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
2663                         }
2664                         
2665                         return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
2666                 }
2667                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
2668                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
2669                         uint32_tArray all_failed_retry_safe_arr = NULL;
2670                         all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2671                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
2672                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
2673                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
2674                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
2675                         }
2676                         
2677                         return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
2678                 }
2679                 case LDKPaymentSendFailure_PartialFailure: {
2680                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
2681                         uint32_tArray results_arr = NULL;
2682                         results_arr = init_arr(results_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2683                         uint32_t *results_arr_ptr = (uint32_t*)(results_arr + 4);
2684                         for (size_t w = 0; w < results_var.datalen; w++) {
2685                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
2686                                 *results_conv_22_conv = results_var.data[w];
2687                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
2688                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
2689                         }
2690                         
2691                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
2692                         uint64_t failed_paths_retry_ref = 0;
2693                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
2694                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2695                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2696                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
2697                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
2698                         }
2699                         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2700                         memcpy((uint8_t*)(payment_id_arr + 4), obj->partial_failure.payment_id.data, 32);
2701                         return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) results_arr; (void) failed_paths_retry_ref; (void) payment_id_arr;
2702                 }
2703                 default: abort();
2704         }
2705 }
2706 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
2707         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2708         CHECK(val->result_ok);
2709         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2710         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2711         return res_arr;
2712 }
2713 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
2714         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
2715         CHECK(!val->result_ok);
2716         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2717         return err_ref;
2718 }
2719 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
2720         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2721         CHECK(val->result_ok);
2722         return *val->contents.result;
2723 }
2724 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
2725         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
2726         CHECK(!val->result_ok);
2727         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2728         return err_ref;
2729 }
2730 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2731         return ThirtyTwoBytes_clone(&tuple->a);
2732 }
2733 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t tuple) {
2734         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2735         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2736         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data, 32);
2737         return ret_arr;
2738 }
2739
2740 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
2741         return ThirtyTwoBytes_clone(&tuple->b);
2742 }
2743 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
2744         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
2745         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2746         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data, 32);
2747         return ret_arr;
2748 }
2749
2750 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t arg) {
2751         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2752         CHECK(val->result_ok);
2753         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
2754         *res_conv = (*val->contents.result);
2755         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
2756         return ((uint64_t)res_conv);
2757 }
2758 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t arg) {
2759         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
2760         CHECK(!val->result_ok);
2761         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2762         return err_ref;
2763 }
2764 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
2765         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
2766         switch(obj->tag) {
2767                 case LDKNetAddress_IPv4: {
2768                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
2769                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
2770                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
2771                 }
2772                 case LDKNetAddress_IPv6: {
2773                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
2774                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
2775                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
2776                 }
2777                 case LDKNetAddress_OnionV2: {
2778                         int8_tArray onion_v2_arr = init_arr(12, sizeof(uint8_t), "Native int8_tArray Bytes");
2779                         memcpy((uint8_t*)(onion_v2_arr + 4), obj->onion_v2.data, 12);
2780                         return 0 /* LDKNetAddress - OnionV2 */; (void) onion_v2_arr;
2781                 }
2782                 case LDKNetAddress_OnionV3: {
2783                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2784                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
2785                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
2786                 }
2787                 default: abort();
2788         }
2789 }
2790 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
2791         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
2792         for (size_t i = 0; i < ret.datalen; i++) {
2793                 ret.data[i] = NetAddress_clone(&orig->data[i]);
2794         }
2795         return ret;
2796 }
2797 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2798         return ThirtyTwoBytes_clone(&tuple->a);
2799 }
2800 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t tuple) {
2801         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2802         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2803         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data, 32);
2804         return ret_arr;
2805 }
2806
2807 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
2808         return ThirtyTwoBytes_clone(&tuple->b);
2809 }
2810 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t tuple) {
2811         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
2812         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2813         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data, 32);
2814         return ret_arr;
2815 }
2816
2817 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t arg) {
2818         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
2819         CHECK(val->result_ok);
2820         LDKC2Tuple_PaymentHashPaymentSecretZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2821         *res_conv = (*val->contents.result);
2822         *res_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(res_conv);
2823         return ((uint64_t)res_conv);
2824 }
2825 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t arg) {
2826         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
2827         CHECK(!val->result_ok);
2828         return *val->contents.err;
2829 }
2830 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t arg) {
2831         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
2832         CHECK(val->result_ok);
2833         LDKC2Tuple_PaymentHashPaymentSecretZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
2834         *res_conv = (*val->contents.result);
2835         *res_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(res_conv);
2836         return ((uint64_t)res_conv);
2837 }
2838 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t arg) {
2839         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
2840         CHECK(!val->result_ok);
2841         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2842         return err_ref;
2843 }
2844 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretNoneZ_get_ok(uint32_t arg) {
2845         LDKCResult_PaymentSecretNoneZ *val = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
2846         CHECK(val->result_ok);
2847         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2848         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2849         return res_arr;
2850 }
2851 void  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretNoneZ_get_err(uint32_t arg) {
2852         LDKCResult_PaymentSecretNoneZ *val = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
2853         CHECK(!val->result_ok);
2854         return *val->contents.err;
2855 }
2856 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
2857         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2858         CHECK(val->result_ok);
2859         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2860         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2861         return res_arr;
2862 }
2863 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
2864         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
2865         CHECK(!val->result_ok);
2866         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2867         return err_ref;
2868 }
2869 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t arg) {
2870         LDKCResult_PaymentPreimageAPIErrorZ *val = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
2871         CHECK(val->result_ok);
2872         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2873         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
2874         return res_arr;
2875 }
2876 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentPreimageAPIErrorZ_get_err(uint32_t arg) {
2877         LDKCResult_PaymentPreimageAPIErrorZ *val = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
2878         CHECK(!val->result_ok);
2879         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
2880         return err_ref;
2881 }
2882 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
2883         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
2884         for (size_t i = 0; i < ret.datalen; i++) {
2885                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
2886         }
2887         return ret;
2888 }
2889 typedef struct LDKWatch_JCalls {
2890         atomic_size_t refcnt;
2891         uint32_t watch_channel_meth;
2892         uint32_t update_channel_meth;
2893         uint32_t release_pending_monitor_events_meth;
2894 } LDKWatch_JCalls;
2895 static void LDKWatch_JCalls_free(void* this_arg) {
2896         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2897         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2898                 js_free(j_calls->watch_channel_meth);
2899                 js_free(j_calls->update_channel_meth);
2900                 js_free(j_calls->release_pending_monitor_events_meth);
2901                 FREE(j_calls);
2902         }
2903 }
2904 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
2905         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2906         LDKOutPoint funding_txo_var = funding_txo;
2907         uint64_t funding_txo_ref = 0;
2908         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2909         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2910         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2911         funding_txo_ref = (uint64_t)funding_txo_var.inner;
2912         if (funding_txo_var.is_owned) {
2913                 funding_txo_ref |= 1;
2914         }
2915         LDKChannelMonitor monitor_var = monitor;
2916         uint64_t monitor_ref = 0;
2917         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2918         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2919         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
2920         monitor_ref = (uint64_t)monitor_var.inner;
2921         if (monitor_var.is_owned) {
2922                 monitor_ref |= 1;
2923         }
2924         uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
2925         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2926         CHECK_ACCESS(ret_ptr);
2927         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
2928         FREE((void*)ret);
2929         return ret_conv;
2930 }
2931 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
2932         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2933         LDKOutPoint funding_txo_var = funding_txo;
2934         uint64_t funding_txo_ref = 0;
2935         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2936         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2937         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2938         funding_txo_ref = (uint64_t)funding_txo_var.inner;
2939         if (funding_txo_var.is_owned) {
2940                 funding_txo_ref |= 1;
2941         }
2942         LDKChannelMonitorUpdate update_var = update;
2943         uint64_t update_ref = 0;
2944         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2945         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2946         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
2947         update_ref = (uint64_t)update_var.inner;
2948         if (update_var.is_owned) {
2949                 update_ref |= 1;
2950         }
2951         uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
2952         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2953         CHECK_ACCESS(ret_ptr);
2954         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
2955         FREE((void*)ret);
2956         return ret_conv;
2957 }
2958 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
2959         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
2960         uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
2961         LDKCVec_MonitorEventZ ret_constr;
2962         ret_constr.datalen = *((uint32_t*)ret);
2963         if (ret_constr.datalen > 0)
2964                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
2965         else
2966                 ret_constr.data = NULL;
2967         uint32_t* ret_vals = (uint32_t*)(ret + 4);
2968         for (size_t o = 0; o < ret_constr.datalen; o++) {
2969                 uint32_t ret_conv_14 = ret_vals[o];
2970                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
2971                 CHECK_ACCESS(ret_conv_14_ptr);
2972                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
2973                 FREE((void*)ret_conv_14);
2974                 ret_constr.data[o] = ret_conv_14_conv;
2975         }
2976         return ret_constr;
2977 }
2978 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
2979         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
2980         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2981 }
2982 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
2983         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
2984         atomic_init(&calls->refcnt, 1);
2985         //TODO: Assign calls->o from o
2986
2987         LDKWatch ret = {
2988                 .this_arg = (void*) calls,
2989                 .watch_channel = watch_channel_LDKWatch_jcall,
2990                 .update_channel = update_channel_LDKWatch_jcall,
2991                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
2992                 .free = LDKWatch_JCalls_free,
2993         };
2994         return ret;
2995 }
2996 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
2997         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
2998         *res_ptr = LDKWatch_init(o);
2999         return (long)res_ptr;
3000 }
3001 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
3002         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3003         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3004         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3005         LDKOutPoint funding_txo_conv;
3006         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3007         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3008         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
3009         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3010         LDKChannelMonitor monitor_conv;
3011         monitor_conv.inner = (void*)(monitor & (~1));
3012         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
3013         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
3014         monitor_conv = ChannelMonitor_clone(&monitor_conv);
3015         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3016         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
3017         return (uint64_t)ret_conv;
3018 }
3019
3020 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
3021         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3022         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3023         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3024         LDKOutPoint funding_txo_conv;
3025         funding_txo_conv.inner = (void*)(funding_txo & (~1));
3026         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
3027         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
3028         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
3029         LDKChannelMonitorUpdate update_conv;
3030         update_conv.inner = (void*)(update & (~1));
3031         update_conv.is_owned = (update & 1) || (update == 0);
3032         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
3033         update_conv = ChannelMonitorUpdate_clone(&update_conv);
3034         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3035         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
3036         return (uint64_t)ret_conv;
3037 }
3038
3039 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
3040         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3042         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
3043         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
3044         uint32_tArray ret_arr = NULL;
3045         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3046         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3047         for (size_t o = 0; o < ret_var.datalen; o++) {
3048                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3049                 *ret_conv_14_copy = ret_var.data[o];
3050                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
3051                 ret_arr_ptr[o] = ret_conv_14_ref;
3052         }
3053         
3054         FREE(ret_var.data);
3055         return ret_arr;
3056 }
3057
3058 typedef struct LDKBroadcasterInterface_JCalls {
3059         atomic_size_t refcnt;
3060         uint32_t broadcast_transaction_meth;
3061 } LDKBroadcasterInterface_JCalls;
3062 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
3063         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3064         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3065                 js_free(j_calls->broadcast_transaction_meth);
3066                 FREE(j_calls);
3067         }
3068 }
3069 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
3070         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
3071         LDKTransaction tx_var = tx;
3072         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3073         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
3074         Transaction_free(tx_var);
3075         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
3076 }
3077 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
3078         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
3079         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3080 }
3081 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
3082         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
3083         atomic_init(&calls->refcnt, 1);
3084         //TODO: Assign calls->o from o
3085
3086         LDKBroadcasterInterface ret = {
3087                 .this_arg = (void*) calls,
3088                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
3089                 .free = LDKBroadcasterInterface_JCalls_free,
3090         };
3091         return ret;
3092 }
3093 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
3094         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
3095         *res_ptr = LDKBroadcasterInterface_init(o);
3096         return (long)res_ptr;
3097 }
3098 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
3099         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3100         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3101         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
3102         LDKTransaction tx_ref;
3103         tx_ref.datalen = *((uint32_t*)tx);
3104         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
3105         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
3106         tx_ref.data_is_owned = true;
3107         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
3108 }
3109
3110 typedef struct LDKKeysInterface_JCalls {
3111         atomic_size_t refcnt;
3112         uint32_t get_node_secret_meth;
3113         uint32_t get_destination_script_meth;
3114         uint32_t get_shutdown_scriptpubkey_meth;
3115         uint32_t get_channel_signer_meth;
3116         uint32_t get_secure_random_bytes_meth;
3117         uint32_t read_chan_signer_meth;
3118         uint32_t sign_invoice_meth;
3119         uint32_t get_inbound_payment_key_material_meth;
3120 } LDKKeysInterface_JCalls;
3121 static void LDKKeysInterface_JCalls_free(void* this_arg) {
3122         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3123         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3124                 js_free(j_calls->get_node_secret_meth);
3125                 js_free(j_calls->get_destination_script_meth);
3126                 js_free(j_calls->get_shutdown_scriptpubkey_meth);
3127                 js_free(j_calls->get_channel_signer_meth);
3128                 js_free(j_calls->get_secure_random_bytes_meth);
3129                 js_free(j_calls->read_chan_signer_meth);
3130                 js_free(j_calls->sign_invoice_meth);
3131                 js_free(j_calls->get_inbound_payment_key_material_meth);
3132                 FREE(j_calls);
3133         }
3134 }
3135 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
3136         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3137         int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
3138         LDKSecretKey ret_ref;
3139         CHECK(*((uint32_t*)ret) == 32);
3140         memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
3141         return ret_ref;
3142 }
3143 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
3144         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3145         int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
3146         LDKCVec_u8Z ret_ref;
3147         ret_ref.datalen = *((uint32_t*)ret);
3148         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3149         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3150         return ret_ref;
3151 }
3152 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
3153         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3154         uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
3155         LDKShutdownScript ret_conv;
3156         ret_conv.inner = (void*)(ret & (~1));
3157         ret_conv.is_owned = (ret & 1) || (ret == 0);
3158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
3159         return ret_conv;
3160 }
3161 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
3162         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3163         uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
3164         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3165         CHECK_ACCESS(ret_ptr);
3166         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
3167         FREE((void*)ret);
3168         return ret_conv;
3169 }
3170 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
3171         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3172         int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
3173         LDKThirtyTwoBytes ret_ref;
3174         CHECK(*((uint32_t*)ret) == 32);
3175         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
3176         return ret_ref;
3177 }
3178 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
3179         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3180         LDKu8slice reader_var = reader;
3181         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3182         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
3183         uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
3184         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3185         CHECK_ACCESS(ret_ptr);
3186         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
3187         FREE((void*)ret);
3188         return ret_conv;
3189 }
3190 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
3191         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3192         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
3193         int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3194         memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
3195         CVec_u8Z_free(invoice_preimage_var);
3196         uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
3197         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3198         CHECK_ACCESS(ret_ptr);
3199         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
3200         FREE((void*)ret);
3201         return ret_conv;
3202 }
3203 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
3204         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
3205         int8_tArray ret = js_invoke_function_0(j_calls->get_inbound_payment_key_material_meth);
3206         LDKThirtyTwoBytes ret_ref;
3207         CHECK(*((uint32_t*)ret) == 32);
3208         memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
3209         return ret_ref;
3210 }
3211 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
3212         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
3213         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3214 }
3215 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
3216         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
3217         atomic_init(&calls->refcnt, 1);
3218         //TODO: Assign calls->o from o
3219
3220         LDKKeysInterface ret = {
3221                 .this_arg = (void*) calls,
3222                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
3223                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
3224                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
3225                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
3226                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
3227                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
3228                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
3229                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
3230                 .free = LDKKeysInterface_JCalls_free,
3231         };
3232         return ret;
3233 }
3234 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
3235         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
3236         *res_ptr = LDKKeysInterface_init(o);
3237         return (long)res_ptr;
3238 }
3239 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
3240         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3241         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3242         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3243         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3244         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
3245         return ret_arr;
3246 }
3247
3248 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
3249         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3250         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3251         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3252         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
3253         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3254         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3255         CVec_u8Z_free(ret_var);
3256         return ret_arr;
3257 }
3258
3259 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
3260         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3261         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3262         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3263         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
3264         uint64_t ret_ref = 0;
3265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3268         ret_ref = (uint64_t)ret_var.inner;
3269         if (ret_var.is_owned) {
3270                 ret_ref |= 1;
3271         }
3272         return ret_ref;
3273 }
3274
3275 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
3276         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3277         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3278         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3279         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3280         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
3281         return (uint64_t)ret_ret;
3282 }
3283
3284 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
3285         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3287         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3288         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3289         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
3290         return ret_arr;
3291 }
3292
3293 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
3294         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3295         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3296         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3297         LDKu8slice reader_ref;
3298         reader_ref.datalen = *((uint32_t*)reader);
3299         reader_ref.data = (int8_t*)(reader + 4);
3300         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
3301         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
3302         return (uint64_t)ret_conv;
3303 }
3304
3305 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
3306         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3307         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3308         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3309         LDKCVec_u8Z invoice_preimage_ref;
3310         invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
3311         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
3312         memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
3313         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
3314         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
3315         return (uint64_t)ret_conv;
3316 }
3317
3318 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
3319         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3320         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3321         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
3322         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3323         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
3324         return ret_arr;
3325 }
3326
3327 typedef struct LDKFeeEstimator_JCalls {
3328         atomic_size_t refcnt;
3329         uint32_t get_est_sat_per_1000_weight_meth;
3330 } LDKFeeEstimator_JCalls;
3331 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
3332         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3333         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3334                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
3335                 FREE(j_calls);
3336         }
3337 }
3338 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
3339         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
3340         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
3341         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
3342 }
3343 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
3344         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
3345         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3346 }
3347 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
3348         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
3349         atomic_init(&calls->refcnt, 1);
3350         //TODO: Assign calls->o from o
3351
3352         LDKFeeEstimator ret = {
3353                 .this_arg = (void*) calls,
3354                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
3355                 .free = LDKFeeEstimator_JCalls_free,
3356         };
3357         return ret;
3358 }
3359 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
3360         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
3361         *res_ptr = LDKFeeEstimator_init(o);
3362         return (long)res_ptr;
3363 }
3364 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
3365         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3366         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3367         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
3368         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
3369         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
3370         return ret_val;
3371 }
3372
3373 typedef struct LDKLogger_JCalls {
3374         atomic_size_t refcnt;
3375         uint32_t log_meth;
3376 } LDKLogger_JCalls;
3377 static void LDKLogger_JCalls_free(void* this_arg) {
3378         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3379         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3380                 js_free(j_calls->log_meth);
3381                 FREE(j_calls);
3382         }
3383 }
3384 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
3385         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
3386         LDKRecord record_var = *record;
3387         uint64_t record_ref = 0;
3388         record_var = Record_clone(record);
3389         CHECK((((uint64_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3390         CHECK((((uint64_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3391         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
3392         record_ref = (uint64_t)record_var.inner;
3393         if (record_var.is_owned) {
3394                 record_ref |= 1;
3395         }
3396         js_invoke_function_1(j_calls->log_meth, record_ref);
3397 }
3398 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
3399         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
3400         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3401 }
3402 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
3403         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
3404         atomic_init(&calls->refcnt, 1);
3405         //TODO: Assign calls->o from o
3406
3407         LDKLogger ret = {
3408                 .this_arg = (void*) calls,
3409                 .log = log_LDKLogger_jcall,
3410                 .free = LDKLogger_JCalls_free,
3411         };
3412         return ret;
3413 }
3414 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
3415         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
3416         *res_ptr = LDKLogger_init(o);
3417         return (long)res_ptr;
3418 }
3419 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3420         return ThirtyTwoBytes_clone(&tuple->a);
3421 }
3422 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t tuple) {
3423         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3424         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3425         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data, 32);
3426         return ret_arr;
3427 }
3428
3429 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
3430         return &tuple->b;
3431 }
3432 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
3433         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
3434         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
3435         uint64_t ret_ref = 0;
3436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3439         ret_ref = (uint64_t)ret_var.inner & ~1;
3440         return ret_ref;
3441 }
3442
3443 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
3444         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3445         CHECK(val->result_ok);
3446         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
3447         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
3448         return ((uint64_t)res_conv) | 1;
3449 }
3450 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
3451         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
3452         CHECK(!val->result_ok);
3453         LDKDecodeError err_var = (*val->contents.err);
3454         uint64_t err_ref = 0;
3455         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3456         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3457         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3458         err_ref = (uint64_t)err_var.inner & ~1;
3459         return err_ref;
3460 }
3461 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
3462         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3463         CHECK(val->result_ok);
3464         LDKChannelConfig res_var = (*val->contents.result);
3465         uint64_t res_ref = 0;
3466         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3467         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3468         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3469         res_ref = (uint64_t)res_var.inner & ~1;
3470         return res_ref;
3471 }
3472 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
3473         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
3474         CHECK(!val->result_ok);
3475         LDKDecodeError err_var = (*val->contents.err);
3476         uint64_t err_ref = 0;
3477         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3478         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3479         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3480         err_ref = (uint64_t)err_var.inner & ~1;
3481         return err_ref;
3482 }
3483 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
3484         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3485         CHECK(val->result_ok);
3486         LDKOutPoint res_var = (*val->contents.result);
3487         uint64_t res_ref = 0;
3488         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3489         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3490         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3491         res_ref = (uint64_t)res_var.inner & ~1;
3492         return res_ref;
3493 }
3494 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
3495         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
3496         CHECK(!val->result_ok);
3497         LDKDecodeError err_var = (*val->contents.err);
3498         uint64_t err_ref = 0;
3499         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3500         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3501         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3502         err_ref = (uint64_t)err_var.inner & ~1;
3503         return err_ref;
3504 }
3505 typedef struct LDKType_JCalls {
3506         atomic_size_t refcnt;
3507         uint32_t type_id_meth;
3508         uint32_t debug_str_meth;
3509         uint32_t write_meth;
3510 } LDKType_JCalls;
3511 static void LDKType_JCalls_free(void* this_arg) {
3512         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3513         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3514                 js_free(j_calls->type_id_meth);
3515                 js_free(j_calls->debug_str_meth);
3516                 js_free(j_calls->write_meth);
3517                 FREE(j_calls);
3518         }
3519 }
3520 uint16_t type_id_LDKType_jcall(const void* this_arg) {
3521         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3522         return js_invoke_function_0(j_calls->type_id_meth);
3523 }
3524 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
3525         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3526         uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
3527         LDKStr ret_conv = str_ref_to_owned_c(ret);
3528         return ret_conv;
3529 }
3530 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
3531         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
3532         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
3533         LDKCVec_u8Z ret_ref;
3534         ret_ref.datalen = *((uint32_t*)ret);
3535         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3536         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
3537         return ret_ref;
3538 }
3539 static void LDKType_JCalls_cloned(LDKType* new_obj) {
3540         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
3541         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3542 }
3543 static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
3544         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
3545         atomic_init(&calls->refcnt, 1);
3546         //TODO: Assign calls->o from o
3547
3548         LDKType ret = {
3549                 .this_arg = (void*) calls,
3550                 .type_id = type_id_LDKType_jcall,
3551                 .debug_str = debug_str_LDKType_jcall,
3552                 .write = write_LDKType_jcall,
3553                 .cloned = LDKType_JCalls_cloned,
3554                 .free = LDKType_JCalls_free,
3555         };
3556         return ret;
3557 }
3558 long  __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
3559         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
3560         *res_ptr = LDKType_init(o);
3561         return (long)res_ptr;
3562 }
3563 int16_t  __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
3564         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3565         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3566         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3567         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
3568         return ret_val;
3569 }
3570
3571 jstring  __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
3572         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3573         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3574         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3575         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
3576         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
3577         Str_free(ret_str);
3578         return ret_conv;
3579 }
3580
3581 int8_tArray  __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
3582         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3583         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3584         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
3585         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3586         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3587         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3588         CVec_u8Z_free(ret_var);
3589         return ret_arr;
3590 }
3591
3592 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
3593         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
3594         switch(obj->tag) {
3595                 case LDKCOption_TypeZ_Some: {
3596                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
3597                         *some_ret = Type_clone(&obj->some);
3598                         return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
3599                 }
3600                 case LDKCOption_TypeZ_None: {
3601                         return 0 /* LDKCOption_TypeZ - None */;
3602                 }
3603                 default: abort();
3604         }
3605 }
3606 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
3607         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3608         CHECK(val->result_ok);
3609         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3610         return res_ref;
3611 }
3612 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
3613         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
3614         CHECK(!val->result_ok);
3615         LDKDecodeError err_var = (*val->contents.err);
3616         uint64_t err_ref = 0;
3617         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3618         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3619         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3620         err_ref = (uint64_t)err_var.inner & ~1;
3621         return err_ref;
3622 }
3623 uint32_t __attribute__((visibility("default"))) TS_LDKPaymentError_ref_from_ptr(uint32_t ptr) {
3624         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
3625         switch(obj->tag) {
3626                 case LDKPaymentError_Invoice: {
3627                         LDKStr invoice_str = obj->invoice;
3628                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
3629                         return 0 /* LDKPaymentError - Invoice */; (void) invoice_conv;
3630                 }
3631                 case LDKPaymentError_Routing: {
3632                         LDKLightningError routing_var = obj->routing;
3633                         uint64_t routing_ref = 0;
3634                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3635                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3636                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
3637                         routing_ref = (uint64_t)routing_var.inner & ~1;
3638                         return 0 /* LDKPaymentError - Routing */; (void) routing_ref;
3639                 }
3640                 case LDKPaymentError_Sending: {
3641                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
3642                         return 0 /* LDKPaymentError - Sending */; (void) sending_ref;
3643                 }
3644                 default: abort();
3645         }
3646 }
3647 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_ok(uint32_t arg) {
3648         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
3649         CHECK(val->result_ok);
3650         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3651         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
3652         return res_arr;
3653 }
3654 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_err(uint32_t arg) {
3655         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
3656         CHECK(!val->result_ok);
3657         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3658         return err_ref;
3659 }
3660 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
3661         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3662         CHECK(val->result_ok);
3663         uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
3664         return res_conv;
3665 }
3666 void  __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
3667         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
3668         CHECK(!val->result_ok);
3669         return *val->contents.err;
3670 }
3671 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
3672         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3673         CHECK(val->result_ok);
3674         LDKInvoice res_var = (*val->contents.result);
3675         uint64_t res_ref = 0;
3676         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3677         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3678         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3679         res_ref = (uint64_t)res_var.inner & ~1;
3680         return res_ref;
3681 }
3682 void  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
3683         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
3684         CHECK(!val->result_ok);
3685         return *val->contents.err;
3686 }
3687 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
3688         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3689         CHECK(val->result_ok);
3690         LDKSignedRawInvoice res_var = (*val->contents.result);
3691         uint64_t res_ref = 0;
3692         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3693         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3694         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3695         res_ref = (uint64_t)res_var.inner & ~1;
3696         return res_ref;
3697 }
3698 void  __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
3699         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
3700         CHECK(!val->result_ok);
3701         return *val->contents.err;
3702 }
3703 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3704         return RawInvoice_clone(&tuple->a);
3705 }
3706 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
3707         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3708         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
3709         uint64_t ret_ref = 0;
3710         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3711         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3713         ret_ref = (uint64_t)ret_var.inner;
3714         if (ret_var.is_owned) {
3715                 ret_ref |= 1;
3716         }
3717         return ret_ref;
3718 }
3719
3720 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3721         return ThirtyTwoBytes_clone(&tuple->b);
3722 }
3723 int8_tArray  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t tuple) {
3724         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3725         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3726         memcpy((uint8_t*)(ret_arr + 4), C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data, 32);
3727         return ret_arr;
3728 }
3729
3730 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
3731         return InvoiceSignature_clone(&tuple->c);
3732 }
3733 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
3734         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
3735         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
3736         uint64_t ret_ref = 0;
3737         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3738         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3740         ret_ref = (uint64_t)ret_var.inner;
3741         if (ret_var.is_owned) {
3742                 ret_ref |= 1;
3743         }
3744         return ret_ref;
3745 }
3746
3747 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
3748         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3749         CHECK(val->result_ok);
3750         LDKPayeePubKey res_var = (*val->contents.result);
3751         uint64_t res_ref = 0;
3752         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3753         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3754         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3755         res_ref = (uint64_t)res_var.inner & ~1;
3756         return res_ref;
3757 }
3758 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
3759         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
3760         CHECK(!val->result_ok);
3761         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3762         return err_conv;
3763 }
3764 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
3765         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
3766         for (size_t i = 0; i < ret.datalen; i++) {
3767                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
3768         }
3769         return ret;
3770 }
3771 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
3772         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3773         CHECK(val->result_ok);
3774         LDKPositiveTimestamp res_var = (*val->contents.result);
3775         uint64_t res_ref = 0;
3776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3778         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3779         res_ref = (uint64_t)res_var.inner & ~1;
3780         return res_ref;
3781 }
3782 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
3783         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
3784         CHECK(!val->result_ok);
3785         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3786         return err_conv;
3787 }
3788 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
3789         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3790         CHECK(val->result_ok);
3791         return *val->contents.result;
3792 }
3793 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
3794         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
3795         CHECK(!val->result_ok);
3796         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3797         return err_conv;
3798 }
3799 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
3800         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3801         CHECK(val->result_ok);
3802         LDKInvoice res_var = (*val->contents.result);
3803         uint64_t res_ref = 0;
3804         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3805         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3806         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3807         res_ref = (uint64_t)res_var.inner & ~1;
3808         return res_ref;
3809 }
3810 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
3811         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
3812         CHECK(!val->result_ok);
3813         uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
3814         return err_conv;
3815 }
3816 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
3817         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3818         CHECK(val->result_ok);
3819         LDKDescription res_var = (*val->contents.result);
3820         uint64_t res_ref = 0;
3821         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3822         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3823         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3824         res_ref = (uint64_t)res_var.inner & ~1;
3825         return res_ref;
3826 }
3827 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
3828         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
3829         CHECK(!val->result_ok);
3830         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3831         return err_conv;
3832 }
3833 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
3834         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3835         CHECK(val->result_ok);
3836         LDKExpiryTime res_var = (*val->contents.result);
3837         uint64_t res_ref = 0;
3838         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3839         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3840         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3841         res_ref = (uint64_t)res_var.inner & ~1;
3842         return res_ref;
3843 }
3844 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
3845         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
3846         CHECK(!val->result_ok);
3847         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3848         return err_conv;
3849 }
3850 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
3851         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3852         CHECK(val->result_ok);
3853         LDKPrivateRoute res_var = (*val->contents.result);
3854         uint64_t res_ref = 0;
3855         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3856         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3857         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3858         res_ref = (uint64_t)res_var.inner & ~1;
3859         return res_ref;
3860 }
3861 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
3862         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
3863         CHECK(!val->result_ok);
3864         uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
3865         return err_conv;
3866 }
3867 jstring  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
3868         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3869         CHECK(val->result_ok);
3870         LDKStr res_str = (*val->contents.result);
3871         jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
3872         return res_conv;
3873 }
3874 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
3875         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
3876         CHECK(!val->result_ok);
3877         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
3878         return err_conv;
3879 }
3880 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3881         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3882         CHECK(val->result_ok);
3883         LDKChannelMonitorUpdate res_var = (*val->contents.result);
3884         uint64_t res_ref = 0;
3885         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3886         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3887         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3888         res_ref = (uint64_t)res_var.inner & ~1;
3889         return res_ref;
3890 }
3891 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
3892         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
3893         CHECK(!val->result_ok);
3894         LDKDecodeError err_var = (*val->contents.err);
3895         uint64_t err_ref = 0;
3896         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3897         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3898         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3899         err_ref = (uint64_t)err_var.inner & ~1;
3900         return err_ref;
3901 }
3902 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_MonitorEventZ_ref_from_ptr(uint32_t ptr) {
3903         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
3904         switch(obj->tag) {
3905                 case LDKCOption_MonitorEventZ_Some: {
3906                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
3907                         return 0 /* LDKCOption_MonitorEventZ - Some */; (void) some_ref;
3908                 }
3909                 case LDKCOption_MonitorEventZ_None: {
3910                         return 0 /* LDKCOption_MonitorEventZ - None */;
3911                 }
3912                 default: abort();
3913         }
3914 }
3915 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t arg) {
3916         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
3917         CHECK(val->result_ok);
3918         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
3919         return res_ref;
3920 }
3921 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t arg) {
3922         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
3923         CHECK(!val->result_ok);
3924         LDKDecodeError err_var = (*val->contents.err);
3925         uint64_t err_ref = 0;
3926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3928         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3929         err_ref = (uint64_t)err_var.inner & ~1;
3930         return err_ref;
3931 }
3932 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
3933         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3934         CHECK(val->result_ok);
3935         LDKHTLCUpdate res_var = (*val->contents.result);
3936         uint64_t res_ref = 0;
3937         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3938         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3939         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3940         res_ref = (uint64_t)res_var.inner & ~1;
3941         return res_ref;
3942 }
3943 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
3944         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
3945         CHECK(!val->result_ok);
3946         LDKDecodeError err_var = (*val->contents.err);
3947         uint64_t err_ref = 0;
3948         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3949         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3950         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3951         err_ref = (uint64_t)err_var.inner & ~1;
3952         return err_ref;
3953 }
3954 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3955         return OutPoint_clone(&tuple->a);
3956 }
3957 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
3958         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3959         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
3960         uint64_t ret_ref = 0;
3961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3964         ret_ref = (uint64_t)ret_var.inner;
3965         if (ret_var.is_owned) {
3966                 ret_ref |= 1;
3967         }
3968         return ret_ref;
3969 }
3970
3971 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
3972         return CVec_u8Z_clone(&tuple->b);
3973 }
3974 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t tuple) {
3975         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
3976         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
3977         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3978         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
3979         CVec_u8Z_free(ret_var);
3980         return ret_arr;
3981 }
3982
3983 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3984         return tuple->a;
3985 }
3986 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t tuple) {
3987         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3988         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
3989         return ret_val;
3990 }
3991
3992 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
3993         return CVec_u8Z_clone(&tuple->b);
3994 }
3995 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t tuple) {
3996         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
3997         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
3998         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3999         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
4000         CVec_u8Z_free(ret_var);
4001         return ret_arr;
4002 }
4003
4004 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
4005         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
4006         for (size_t i = 0; i < ret.datalen; i++) {
4007                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
4008         }
4009         return ret;
4010 }
4011 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
4012         return ThirtyTwoBytes_clone(&tuple->a);
4013 }
4014 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t tuple) {
4015         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
4016         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4017         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data, 32);
4018         return ret_arr;
4019 }
4020
4021 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
4022         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
4023 }
4024 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
4025         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
4026         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
4027         uint32_tArray ret_arr = NULL;
4028         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4029         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4030         for (size_t v = 0; v < ret_var.datalen; v++) {
4031                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
4032                 *ret_conv_21_conv = ret_var.data[v];
4033                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
4034         }
4035         
4036         FREE(ret_var.data);
4037         return ret_arr;
4038 }
4039
4040 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
4041         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
4042         for (size_t i = 0; i < ret.datalen; i++) {
4043                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
4044         }
4045         return ret;
4046 }
4047 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
4048         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
4049         for (size_t i = 0; i < ret.datalen; i++) {
4050                 ret.data[i] = Event_clone(&orig->data[i]);
4051         }
4052         return ret;
4053 }
4054 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
4055         return tuple->a;
4056 }
4057 int32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t tuple) {
4058         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
4059         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
4060         return ret_val;
4061 }
4062
4063 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
4064         return TxOut_clone(&tuple->b);
4065 }
4066 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t tuple) {
4067         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
4068         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4069         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
4070         return (uint64_t)ret_ref;
4071 }
4072
4073 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
4074         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
4075         for (size_t i = 0; i < ret.datalen; i++) {
4076                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
4077         }
4078         return ret;
4079 }
4080 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
4081         return ThirtyTwoBytes_clone(&tuple->a);
4082 }
4083 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t tuple) {
4084         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
4085         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4086         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data, 32);
4087         return ret_arr;
4088 }
4089
4090 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
4091         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
4092 }
4093 uint32_tArray  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
4094         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
4095         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
4096         uint32_tArray ret_arr = NULL;
4097         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4098         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4099         for (size_t u = 0; u < ret_var.datalen; u++) {
4100                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4101                 *ret_conv_20_conv = ret_var.data[u];
4102                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
4103         }
4104         
4105         FREE(ret_var.data);
4106         return ret_arr;
4107 }
4108
4109 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
4110         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
4111         for (size_t i = 0; i < ret.datalen; i++) {
4112                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
4113         }
4114         return ret;
4115 }
4116 uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
4117         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
4118         switch(obj->tag) {
4119                 case LDKBalance_ClaimableOnChannelClose: {
4120                         return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
4121                 }
4122                 case LDKBalance_ClaimableAwaitingConfirmations: {
4123                         return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
4124                 }
4125                 case LDKBalance_ContentiousClaimable: {
4126                         return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
4127                 }
4128                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
4129                         return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
4130                 }
4131                 default: abort();
4132         }
4133 }
4134 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
4135         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
4136         for (size_t i = 0; i < ret.datalen; i++) {
4137                 ret.data[i] = Balance_clone(&orig->data[i]);
4138         }
4139         return ret;
4140 }
4141 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
4142         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4143         CHECK(val->result_ok);
4144         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4145         *res_conv = (*val->contents.result);
4146         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
4147         return ((uint64_t)res_conv);
4148 }
4149 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
4150         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
4151         CHECK(!val->result_ok);
4152         LDKDecodeError err_var = (*val->contents.err);
4153         uint64_t err_ref = 0;
4154         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4155         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4156         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4157         err_ref = (uint64_t)err_var.inner & ~1;
4158         return err_ref;
4159 }
4160 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
4161         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4162         CHECK(val->result_ok);
4163         return *val->contents.result;
4164 }
4165 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
4166         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
4167         CHECK(!val->result_ok);
4168         LDKLightningError err_var = (*val->contents.err);
4169         uint64_t err_ref = 0;
4170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4172         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4173         err_ref = (uint64_t)err_var.inner & ~1;
4174         return err_ref;
4175 }
4176 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4177         return tuple->a;
4178 }
4179 int8_tArray  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t tuple) {
4180         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4181         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4182         memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form, 33);
4183         return ret_arr;
4184 }
4185
4186 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
4187         return Type_clone(&tuple->b);
4188 }
4189 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
4190         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
4191         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
4192         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
4193         return (uint64_t)ret_ret;
4194 }
4195
4196 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
4197         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
4198         for (size_t i = 0; i < ret.datalen; i++) {
4199                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
4200         }
4201         return ret;
4202 }
4203 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
4204         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4205         CHECK(val->result_ok);
4206         return *val->contents.result;
4207 }
4208 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
4209         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
4210         CHECK(!val->result_ok);
4211         LDKLightningError err_var = (*val->contents.err);
4212         uint64_t err_ref = 0;
4213         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4214         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4215         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4216         err_ref = (uint64_t)err_var.inner & ~1;
4217         return err_ref;
4218 }
4219 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4220         return ChannelAnnouncement_clone(&tuple->a);
4221 }
4222 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
4223         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4224         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
4225         uint64_t ret_ref = 0;
4226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4229         ret_ref = (uint64_t)ret_var.inner;
4230         if (ret_var.is_owned) {
4231                 ret_ref |= 1;
4232         }
4233         return ret_ref;
4234 }
4235
4236 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4237         return ChannelUpdate_clone(&tuple->b);
4238 }
4239 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
4240         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4241         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
4242         uint64_t ret_ref = 0;
4243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4246         ret_ref = (uint64_t)ret_var.inner;
4247         if (ret_var.is_owned) {
4248                 ret_ref |= 1;
4249         }
4250         return ret_ref;
4251 }
4252
4253 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
4254         return ChannelUpdate_clone(&tuple->c);
4255 }
4256 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
4257         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
4258         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
4259         uint64_t ret_ref = 0;
4260         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4261         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4263         ret_ref = (uint64_t)ret_var.inner;
4264         if (ret_var.is_owned) {
4265                 ret_ref |= 1;
4266         }
4267         return ret_ref;
4268 }
4269
4270 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
4271         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
4272         for (size_t i = 0; i < ret.datalen; i++) {
4273                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
4274         }
4275         return ret;
4276 }
4277 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
4278         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
4279         for (size_t i = 0; i < ret.datalen; i++) {
4280                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
4281         }
4282         return ret;
4283 }
4284 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
4285         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4286         CHECK(val->result_ok);
4287         LDKCVec_u8Z res_var = (*val->contents.result);
4288         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4289         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
4290         return res_arr;
4291 }
4292 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
4293         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
4294         CHECK(!val->result_ok);
4295         LDKPeerHandleError err_var = (*val->contents.err);
4296         uint64_t err_ref = 0;
4297         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4298         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4299         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4300         err_ref = (uint64_t)err_var.inner & ~1;
4301         return err_ref;
4302 }
4303 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
4304         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4305         CHECK(val->result_ok);
4306         return *val->contents.result;
4307 }
4308 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
4309         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
4310         CHECK(!val->result_ok);
4311         LDKPeerHandleError err_var = (*val->contents.err);
4312         uint64_t err_ref = 0;
4313         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4314         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4315         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4316         err_ref = (uint64_t)err_var.inner & ~1;
4317         return err_ref;
4318 }
4319 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
4320         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4321         CHECK(val->result_ok);
4322         return *val->contents.result;
4323 }
4324 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
4325         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
4326         CHECK(!val->result_ok);
4327         LDKPeerHandleError err_var = (*val->contents.err);
4328         uint64_t err_ref = 0;
4329         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4330         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4331         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4332         err_ref = (uint64_t)err_var.inner & ~1;
4333         return err_ref;
4334 }
4335 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_ok(uint32_t arg) {
4336         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4337         CHECK(val->result_ok);
4338         LDKNodeId res_var = (*val->contents.result);
4339         uint64_t res_ref = 0;
4340         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4341         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4342         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4343         res_ref = (uint64_t)res_var.inner & ~1;
4344         return res_ref;
4345 }
4346 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
4347         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
4348         CHECK(!val->result_ok);
4349         LDKDecodeError err_var = (*val->contents.err);
4350         uint64_t err_ref = 0;
4351         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4352         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4353         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4354         err_ref = (uint64_t)err_var.inner & ~1;
4355         return err_ref;
4356 }
4357 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t arg) {
4358         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
4359         CHECK(val->result_ok);
4360         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4361         return res_ref;
4362 }
4363 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t arg) {
4364         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
4365         CHECK(!val->result_ok);
4366         LDKDecodeError err_var = (*val->contents.err);
4367         uint64_t err_ref = 0;
4368         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4369         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4370         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4371         err_ref = (uint64_t)err_var.inner & ~1;
4372         return err_ref;
4373 }
4374 typedef struct LDKAccess_JCalls {
4375         atomic_size_t refcnt;
4376         uint32_t get_utxo_meth;
4377 } LDKAccess_JCalls;
4378 static void LDKAccess_JCalls_free(void* this_arg) {
4379         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4380         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4381                 js_free(j_calls->get_utxo_meth);
4382                 FREE(j_calls);
4383         }
4384 }
4385 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4386         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4387         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
4388         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
4389         uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
4390         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4391         CHECK_ACCESS(ret_ptr);
4392         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4393         FREE((void*)ret);
4394         return ret_conv;
4395 }
4396 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4397         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4398         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4399 }
4400 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
4401         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4402         atomic_init(&calls->refcnt, 1);
4403         //TODO: Assign calls->o from o
4404
4405         LDKAccess ret = {
4406                 .this_arg = (void*) calls,
4407                 .get_utxo = get_utxo_LDKAccess_jcall,
4408                 .free = LDKAccess_JCalls_free,
4409         };
4410         return ret;
4411 }
4412 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
4413         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4414         *res_ptr = LDKAccess_init(o);
4415         return (long)res_ptr;
4416 }
4417 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
4418         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4419         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4420         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4421         unsigned char genesis_hash_arr[32];
4422         CHECK(*((uint32_t*)genesis_hash) == 32);
4423         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
4424         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4425         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4426         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4427         return (uint64_t)ret_conv;
4428 }
4429
4430 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
4431         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
4432         switch(obj->tag) {
4433                 case LDKCOption_AccessZ_Some: {
4434                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4435                         *some_ret = obj->some;
4436                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
4437                         return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
4438                 }
4439                 case LDKCOption_AccessZ_None: {
4440                         return 0 /* LDKCOption_AccessZ - None */;
4441                 }
4442                 default: abort();
4443         }
4444 }
4445 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4446         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4447         CHECK(val->result_ok);
4448         LDKDirectionalChannelInfo res_var = (*val->contents.result);
4449         uint64_t res_ref = 0;
4450         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4451         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4452         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4453         res_ref = (uint64_t)res_var.inner & ~1;
4454         return res_ref;
4455 }
4456 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4457         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
4458         CHECK(!val->result_ok);
4459         LDKDecodeError err_var = (*val->contents.err);
4460         uint64_t err_ref = 0;
4461         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4462         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4463         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4464         err_ref = (uint64_t)err_var.inner & ~1;
4465         return err_ref;
4466 }
4467 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
4468         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4469         CHECK(val->result_ok);
4470         LDKChannelInfo res_var = (*val->contents.result);
4471         uint64_t res_ref = 0;
4472         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4473         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4474         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4475         res_ref = (uint64_t)res_var.inner & ~1;
4476         return res_ref;
4477 }
4478 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
4479         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
4480         CHECK(!val->result_ok);
4481         LDKDecodeError err_var = (*val->contents.err);
4482         uint64_t err_ref = 0;
4483         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4484         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4485         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4486         err_ref = (uint64_t)err_var.inner & ~1;
4487         return err_ref;
4488 }
4489 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
4490         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4491         CHECK(val->result_ok);
4492         LDKRoutingFees res_var = (*val->contents.result);
4493         uint64_t res_ref = 0;
4494         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4495         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4496         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4497         res_ref = (uint64_t)res_var.inner & ~1;
4498         return res_ref;
4499 }
4500 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
4501         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
4502         CHECK(!val->result_ok);
4503         LDKDecodeError err_var = (*val->contents.err);
4504         uint64_t err_ref = 0;
4505         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4506         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4507         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4508         err_ref = (uint64_t)err_var.inner & ~1;
4509         return err_ref;
4510 }
4511 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
4512         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4513         CHECK(val->result_ok);
4514         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
4515         uint64_t res_ref = 0;
4516         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4517         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4518         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4519         res_ref = (uint64_t)res_var.inner & ~1;
4520         return res_ref;
4521 }
4522 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
4523         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
4524         CHECK(!val->result_ok);
4525         LDKDecodeError err_var = (*val->contents.err);
4526         uint64_t err_ref = 0;
4527         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4528         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4529         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4530         err_ref = (uint64_t)err_var.inner & ~1;
4531         return err_ref;
4532 }
4533 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
4534         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
4535         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
4536         return ret;
4537 }
4538 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
4539         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4540         CHECK(val->result_ok);
4541         LDKNodeInfo res_var = (*val->contents.result);
4542         uint64_t res_ref = 0;
4543         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4544         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4545         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4546         res_ref = (uint64_t)res_var.inner & ~1;
4547         return res_ref;
4548 }
4549 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
4550         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
4551         CHECK(!val->result_ok);
4552         LDKDecodeError err_var = (*val->contents.err);
4553         uint64_t err_ref = 0;
4554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4556         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4557         err_ref = (uint64_t)err_var.inner & ~1;
4558         return err_ref;
4559 }
4560 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
4561         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4562         CHECK(val->result_ok);
4563         LDKNetworkGraph res_var = (*val->contents.result);
4564         uint64_t res_ref = 0;
4565         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4566         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4567         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4568         res_ref = (uint64_t)res_var.inner & ~1;
4569         return res_ref;
4570 }
4571 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
4572         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
4573         CHECK(!val->result_ok);
4574         LDKDecodeError err_var = (*val->contents.err);
4575         uint64_t err_ref = 0;
4576         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4577         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4578         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4579         err_ref = (uint64_t)err_var.inner & ~1;
4580         return err_ref;
4581 }
4582 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
4583         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4584         switch(obj->tag) {
4585                 case LDKCOption_CVec_NetAddressZZ_Some: {
4586                         LDKCVec_NetAddressZ some_var = obj->some;
4587                         uint32_tArray some_arr = NULL;
4588                         some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4589                         uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
4590                         for (size_t m = 0; m < some_var.datalen; m++) {
4591                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
4592                                 some_arr_ptr[m] = some_conv_12_ref;
4593                         }
4594                         
4595                         return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
4596                 }
4597                 case LDKCOption_CVec_NetAddressZZ_None: {
4598                         return 0 /* LDKCOption_CVec_NetAddressZZ - None */;
4599                 }
4600                 default: abort();
4601         }
4602 }
4603 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
4604         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4605         CHECK(val->result_ok);
4606         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
4607         return res_ref;
4608 }
4609 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
4610         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
4611         CHECK(!val->result_ok);
4612         LDKDecodeError err_var = (*val->contents.err);
4613         uint64_t err_ref = 0;
4614         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4615         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4616         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4617         err_ref = (uint64_t)err_var.inner & ~1;
4618         return err_ref;
4619 }
4620 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4621         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4622         for (size_t i = 0; i < ret.datalen; i++) {
4623                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4624         }
4625         return ret;
4626 }
4627 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4628         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4629         for (size_t i = 0; i < ret.datalen; i++) {
4630                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4631         }
4632         return ret;
4633 }
4634 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4635         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4636         for (size_t i = 0; i < ret.datalen; i++) {
4637                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4638         }
4639         return ret;
4640 }
4641 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4642         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4643         for (size_t i = 0; i < ret.datalen; i++) {
4644                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4645         }
4646         return ret;
4647 }
4648 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
4649         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4650         CHECK(val->result_ok);
4651         LDKAcceptChannel res_var = (*val->contents.result);
4652         uint64_t res_ref = 0;
4653         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4654         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4655         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4656         res_ref = (uint64_t)res_var.inner & ~1;
4657         return res_ref;
4658 }
4659 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
4660         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
4661         CHECK(!val->result_ok);
4662         LDKDecodeError err_var = (*val->contents.err);
4663         uint64_t err_ref = 0;
4664         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4665         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4666         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4667         err_ref = (uint64_t)err_var.inner & ~1;
4668         return err_ref;
4669 }
4670 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
4671         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4672         CHECK(val->result_ok);
4673         LDKAnnouncementSignatures res_var = (*val->contents.result);
4674         uint64_t res_ref = 0;
4675         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4676         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4677         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4678         res_ref = (uint64_t)res_var.inner & ~1;
4679         return res_ref;
4680 }
4681 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
4682         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
4683         CHECK(!val->result_ok);
4684         LDKDecodeError err_var = (*val->contents.err);
4685         uint64_t err_ref = 0;
4686         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4687         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4688         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4689         err_ref = (uint64_t)err_var.inner & ~1;
4690         return err_ref;
4691 }
4692 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
4693         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4694         CHECK(val->result_ok);
4695         LDKChannelReestablish res_var = (*val->contents.result);
4696         uint64_t res_ref = 0;
4697         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4698         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4699         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4700         res_ref = (uint64_t)res_var.inner & ~1;
4701         return res_ref;
4702 }
4703 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
4704         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
4705         CHECK(!val->result_ok);
4706         LDKDecodeError err_var = (*val->contents.err);
4707         uint64_t err_ref = 0;
4708         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4709         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4710         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4711         err_ref = (uint64_t)err_var.inner & ~1;
4712         return err_ref;
4713 }
4714 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4715         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4716         CHECK(val->result_ok);
4717         LDKClosingSigned res_var = (*val->contents.result);
4718         uint64_t res_ref = 0;
4719         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4720         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4721         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4722         res_ref = (uint64_t)res_var.inner & ~1;
4723         return res_ref;
4724 }
4725 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
4726         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
4727         CHECK(!val->result_ok);
4728         LDKDecodeError err_var = (*val->contents.err);
4729         uint64_t err_ref = 0;
4730         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4731         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4732         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4733         err_ref = (uint64_t)err_var.inner & ~1;
4734         return err_ref;
4735 }
4736 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
4737         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4738         CHECK(val->result_ok);
4739         LDKClosingSignedFeeRange res_var = (*val->contents.result);
4740         uint64_t res_ref = 0;
4741         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4742         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4743         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4744         res_ref = (uint64_t)res_var.inner & ~1;
4745         return res_ref;
4746 }
4747 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
4748         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
4749         CHECK(!val->result_ok);
4750         LDKDecodeError err_var = (*val->contents.err);
4751         uint64_t err_ref = 0;
4752         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4753         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4754         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4755         err_ref = (uint64_t)err_var.inner & ~1;
4756         return err_ref;
4757 }
4758 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
4759         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4760         CHECK(val->result_ok);
4761         LDKCommitmentSigned res_var = (*val->contents.result);
4762         uint64_t res_ref = 0;
4763         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4764         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4765         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4766         res_ref = (uint64_t)res_var.inner & ~1;
4767         return res_ref;
4768 }
4769 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
4770         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
4771         CHECK(!val->result_ok);
4772         LDKDecodeError err_var = (*val->contents.err);
4773         uint64_t err_ref = 0;
4774         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4775         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4776         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4777         err_ref = (uint64_t)err_var.inner & ~1;
4778         return err_ref;
4779 }
4780 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
4781         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4782         CHECK(val->result_ok);
4783         LDKFundingCreated res_var = (*val->contents.result);
4784         uint64_t res_ref = 0;
4785         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4786         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4787         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4788         res_ref = (uint64_t)res_var.inner & ~1;
4789         return res_ref;
4790 }
4791 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
4792         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
4793         CHECK(!val->result_ok);
4794         LDKDecodeError err_var = (*val->contents.err);
4795         uint64_t err_ref = 0;
4796         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4797         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4798         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4799         err_ref = (uint64_t)err_var.inner & ~1;
4800         return err_ref;
4801 }
4802 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
4803         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4804         CHECK(val->result_ok);
4805         LDKFundingSigned res_var = (*val->contents.result);
4806         uint64_t res_ref = 0;
4807         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4808         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4809         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4810         res_ref = (uint64_t)res_var.inner & ~1;
4811         return res_ref;
4812 }
4813 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
4814         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
4815         CHECK(!val->result_ok);
4816         LDKDecodeError err_var = (*val->contents.err);
4817         uint64_t err_ref = 0;
4818         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4819         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4820         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4821         err_ref = (uint64_t)err_var.inner & ~1;
4822         return err_ref;
4823 }
4824 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
4825         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4826         CHECK(val->result_ok);
4827         LDKFundingLocked res_var = (*val->contents.result);
4828         uint64_t res_ref = 0;
4829         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4830         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4831         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4832         res_ref = (uint64_t)res_var.inner & ~1;
4833         return res_ref;
4834 }
4835 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
4836         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
4837         CHECK(!val->result_ok);
4838         LDKDecodeError err_var = (*val->contents.err);
4839         uint64_t err_ref = 0;
4840         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4841         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4842         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4843         err_ref = (uint64_t)err_var.inner & ~1;
4844         return err_ref;
4845 }
4846 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
4847         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4848         CHECK(val->result_ok);
4849         LDKInit res_var = (*val->contents.result);
4850         uint64_t res_ref = 0;
4851         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4852         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4853         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4854         res_ref = (uint64_t)res_var.inner & ~1;
4855         return res_ref;
4856 }
4857 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
4858         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
4859         CHECK(!val->result_ok);
4860         LDKDecodeError err_var = (*val->contents.err);
4861         uint64_t err_ref = 0;
4862         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4863         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4864         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4865         err_ref = (uint64_t)err_var.inner & ~1;
4866         return err_ref;
4867 }
4868 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
4869         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4870         CHECK(val->result_ok);
4871         LDKOpenChannel res_var = (*val->contents.result);
4872         uint64_t res_ref = 0;
4873         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4874         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4875         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4876         res_ref = (uint64_t)res_var.inner & ~1;
4877         return res_ref;
4878 }
4879 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
4880         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
4881         CHECK(!val->result_ok);
4882         LDKDecodeError err_var = (*val->contents.err);
4883         uint64_t err_ref = 0;
4884         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4885         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4886         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4887         err_ref = (uint64_t)err_var.inner & ~1;
4888         return err_ref;
4889 }
4890 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
4891         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4892         CHECK(val->result_ok);
4893         LDKRevokeAndACK res_var = (*val->contents.result);
4894         uint64_t res_ref = 0;
4895         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4896         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4897         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4898         res_ref = (uint64_t)res_var.inner & ~1;
4899         return res_ref;
4900 }
4901 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
4902         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
4903         CHECK(!val->result_ok);
4904         LDKDecodeError err_var = (*val->contents.err);
4905         uint64_t err_ref = 0;
4906         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4907         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4908         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4909         err_ref = (uint64_t)err_var.inner & ~1;
4910         return err_ref;
4911 }
4912 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
4913         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4914         CHECK(val->result_ok);
4915         LDKShutdown res_var = (*val->contents.result);
4916         uint64_t res_ref = 0;
4917         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4918         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4919         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4920         res_ref = (uint64_t)res_var.inner & ~1;
4921         return res_ref;
4922 }
4923 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
4924         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
4925         CHECK(!val->result_ok);
4926         LDKDecodeError err_var = (*val->contents.err);
4927         uint64_t err_ref = 0;
4928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4930         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4931         err_ref = (uint64_t)err_var.inner & ~1;
4932         return err_ref;
4933 }
4934 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4935         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4936         CHECK(val->result_ok);
4937         LDKUpdateFailHTLC res_var = (*val->contents.result);
4938         uint64_t res_ref = 0;
4939         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4940         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4941         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4942         res_ref = (uint64_t)res_var.inner & ~1;
4943         return res_ref;
4944 }
4945 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
4946         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
4947         CHECK(!val->result_ok);
4948         LDKDecodeError err_var = (*val->contents.err);
4949         uint64_t err_ref = 0;
4950         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4951         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4952         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4953         err_ref = (uint64_t)err_var.inner & ~1;
4954         return err_ref;
4955 }
4956 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
4957         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4958         CHECK(val->result_ok);
4959         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
4960         uint64_t res_ref = 0;
4961         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4962         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4963         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4964         res_ref = (uint64_t)res_var.inner & ~1;
4965         return res_ref;
4966 }
4967 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
4968         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
4969         CHECK(!val->result_ok);
4970         LDKDecodeError err_var = (*val->contents.err);
4971         uint64_t err_ref = 0;
4972         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4973         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4974         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4975         err_ref = (uint64_t)err_var.inner & ~1;
4976         return err_ref;
4977 }
4978 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
4979         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4980         CHECK(val->result_ok);
4981         LDKUpdateFee res_var = (*val->contents.result);
4982         uint64_t res_ref = 0;
4983         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4984         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4985         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4986         res_ref = (uint64_t)res_var.inner & ~1;
4987         return res_ref;
4988 }
4989 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
4990         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
4991         CHECK(!val->result_ok);
4992         LDKDecodeError err_var = (*val->contents.err);
4993         uint64_t err_ref = 0;
4994         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4995         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4996         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4997         err_ref = (uint64_t)err_var.inner & ~1;
4998         return err_ref;
4999 }
5000 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5001         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5002         CHECK(val->result_ok);
5003         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
5004         uint64_t res_ref = 0;
5005         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5006         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5007         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5008         res_ref = (uint64_t)res_var.inner & ~1;
5009         return res_ref;
5010 }
5011 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
5012         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
5013         CHECK(!val->result_ok);
5014         LDKDecodeError err_var = (*val->contents.err);
5015         uint64_t err_ref = 0;
5016         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5017         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5018         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5019         err_ref = (uint64_t)err_var.inner & ~1;
5020         return err_ref;
5021 }
5022 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
5023         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5024         CHECK(val->result_ok);
5025         LDKUpdateAddHTLC res_var = (*val->contents.result);
5026         uint64_t res_ref = 0;
5027         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5028         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5029         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5030         res_ref = (uint64_t)res_var.inner & ~1;
5031         return res_ref;
5032 }
5033 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
5034         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
5035         CHECK(!val->result_ok);
5036         LDKDecodeError err_var = (*val->contents.err);
5037         uint64_t err_ref = 0;
5038         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5039         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5040         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5041         err_ref = (uint64_t)err_var.inner & ~1;
5042         return err_ref;
5043 }
5044 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
5045         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5046         CHECK(val->result_ok);
5047         LDKPing res_var = (*val->contents.result);
5048         uint64_t res_ref = 0;
5049         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5050         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5051         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5052         res_ref = (uint64_t)res_var.inner & ~1;
5053         return res_ref;
5054 }
5055 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
5056         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
5057         CHECK(!val->result_ok);
5058         LDKDecodeError err_var = (*val->contents.err);
5059         uint64_t err_ref = 0;
5060         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5061         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5062         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5063         err_ref = (uint64_t)err_var.inner & ~1;
5064         return err_ref;
5065 }
5066 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
5067         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5068         CHECK(val->result_ok);
5069         LDKPong res_var = (*val->contents.result);
5070         uint64_t res_ref = 0;
5071         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5072         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5073         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5074         res_ref = (uint64_t)res_var.inner & ~1;
5075         return res_ref;
5076 }
5077 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
5078         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
5079         CHECK(!val->result_ok);
5080         LDKDecodeError err_var = (*val->contents.err);
5081         uint64_t err_ref = 0;
5082         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5083         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5084         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5085         err_ref = (uint64_t)err_var.inner & ~1;
5086         return err_ref;
5087 }
5088 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5089         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5090         CHECK(val->result_ok);
5091         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
5092         uint64_t res_ref = 0;
5093         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5094         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5095         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5096         res_ref = (uint64_t)res_var.inner & ~1;
5097         return res_ref;
5098 }
5099 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5100         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5101         CHECK(!val->result_ok);
5102         LDKDecodeError err_var = (*val->contents.err);
5103         uint64_t err_ref = 0;
5104         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5105         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5106         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5107         err_ref = (uint64_t)err_var.inner & ~1;
5108         return err_ref;
5109 }
5110 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5111         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5112         CHECK(val->result_ok);
5113         LDKChannelAnnouncement res_var = (*val->contents.result);
5114         uint64_t res_ref = 0;
5115         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5116         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5117         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5118         res_ref = (uint64_t)res_var.inner & ~1;
5119         return res_ref;
5120 }
5121 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5122         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
5123         CHECK(!val->result_ok);
5124         LDKDecodeError err_var = (*val->contents.err);
5125         uint64_t err_ref = 0;
5126         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5127         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5128         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5129         err_ref = (uint64_t)err_var.inner & ~1;
5130         return err_ref;
5131 }
5132 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5133         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5134         CHECK(val->result_ok);
5135         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
5136         uint64_t res_ref = 0;
5137         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5138         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5139         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5140         res_ref = (uint64_t)res_var.inner & ~1;
5141         return res_ref;
5142 }
5143 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5144         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
5145         CHECK(!val->result_ok);
5146         LDKDecodeError err_var = (*val->contents.err);
5147         uint64_t err_ref = 0;
5148         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5149         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5150         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5151         err_ref = (uint64_t)err_var.inner & ~1;
5152         return err_ref;
5153 }
5154 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
5155         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5156         CHECK(val->result_ok);
5157         LDKChannelUpdate res_var = (*val->contents.result);
5158         uint64_t res_ref = 0;
5159         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5160         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5161         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5162         res_ref = (uint64_t)res_var.inner & ~1;
5163         return res_ref;
5164 }
5165 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
5166         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
5167         CHECK(!val->result_ok);
5168         LDKDecodeError err_var = (*val->contents.err);
5169         uint64_t err_ref = 0;
5170         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5171         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5172         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5173         err_ref = (uint64_t)err_var.inner & ~1;
5174         return err_ref;
5175 }
5176 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
5177         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5178         CHECK(val->result_ok);
5179         LDKErrorMessage res_var = (*val->contents.result);
5180         uint64_t res_ref = 0;
5181         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5182         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5183         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5184         res_ref = (uint64_t)res_var.inner & ~1;
5185         return res_ref;
5186 }
5187 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
5188         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
5189         CHECK(!val->result_ok);
5190         LDKDecodeError err_var = (*val->contents.err);
5191         uint64_t err_ref = 0;
5192         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5193         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5194         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5195         err_ref = (uint64_t)err_var.inner & ~1;
5196         return err_ref;
5197 }
5198 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5199         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5200         CHECK(val->result_ok);
5201         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
5202         uint64_t res_ref = 0;
5203         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5204         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5205         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5206         res_ref = (uint64_t)res_var.inner & ~1;
5207         return res_ref;
5208 }
5209 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5210         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
5211         CHECK(!val->result_ok);
5212         LDKDecodeError err_var = (*val->contents.err);
5213         uint64_t err_ref = 0;
5214         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5215         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5216         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5217         err_ref = (uint64_t)err_var.inner & ~1;
5218         return err_ref;
5219 }
5220 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
5221         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5222         CHECK(val->result_ok);
5223         LDKNodeAnnouncement res_var = (*val->contents.result);
5224         uint64_t res_ref = 0;
5225         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5226         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5227         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5228         res_ref = (uint64_t)res_var.inner & ~1;
5229         return res_ref;
5230 }
5231 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
5232         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
5233         CHECK(!val->result_ok);
5234         LDKDecodeError err_var = (*val->contents.err);
5235         uint64_t err_ref = 0;
5236         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5237         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5238         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5239         err_ref = (uint64_t)err_var.inner & ~1;
5240         return err_ref;
5241 }
5242 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
5243         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5244         CHECK(val->result_ok);
5245         LDKQueryShortChannelIds res_var = (*val->contents.result);
5246         uint64_t res_ref = 0;
5247         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5248         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5249         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5250         res_ref = (uint64_t)res_var.inner & ~1;
5251         return res_ref;
5252 }
5253 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
5254         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
5255         CHECK(!val->result_ok);
5256         LDKDecodeError err_var = (*val->contents.err);
5257         uint64_t err_ref = 0;
5258         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5259         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5260         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5261         err_ref = (uint64_t)err_var.inner & ~1;
5262         return err_ref;
5263 }
5264 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
5265         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5266         CHECK(val->result_ok);
5267         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
5268         uint64_t res_ref = 0;
5269         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5270         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5271         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5272         res_ref = (uint64_t)res_var.inner & ~1;
5273         return res_ref;
5274 }
5275 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
5276         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
5277         CHECK(!val->result_ok);
5278         LDKDecodeError err_var = (*val->contents.err);
5279         uint64_t err_ref = 0;
5280         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5281         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5282         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5283         err_ref = (uint64_t)err_var.inner & ~1;
5284         return err_ref;
5285 }
5286 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5287         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5288         CHECK(val->result_ok);
5289         LDKQueryChannelRange res_var = (*val->contents.result);
5290         uint64_t res_ref = 0;
5291         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5294         res_ref = (uint64_t)res_var.inner & ~1;
5295         return res_ref;
5296 }
5297 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5298         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
5299         CHECK(!val->result_ok);
5300         LDKDecodeError err_var = (*val->contents.err);
5301         uint64_t err_ref = 0;
5302         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5303         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5304         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5305         err_ref = (uint64_t)err_var.inner & ~1;
5306         return err_ref;
5307 }
5308 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
5309         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5310         CHECK(val->result_ok);
5311         LDKReplyChannelRange res_var = (*val->contents.result);
5312         uint64_t res_ref = 0;
5313         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5314         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5315         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5316         res_ref = (uint64_t)res_var.inner & ~1;
5317         return res_ref;
5318 }
5319 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
5320         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
5321         CHECK(!val->result_ok);
5322         LDKDecodeError err_var = (*val->contents.err);
5323         uint64_t err_ref = 0;
5324         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5325         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5326         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5327         err_ref = (uint64_t)err_var.inner & ~1;
5328         return err_ref;
5329 }
5330 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
5331         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5332         CHECK(val->result_ok);
5333         LDKGossipTimestampFilter res_var = (*val->contents.result);
5334         uint64_t res_ref = 0;
5335         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5336         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5337         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5338         res_ref = (uint64_t)res_var.inner & ~1;
5339         return res_ref;
5340 }
5341 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
5342         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
5343         CHECK(!val->result_ok);
5344         LDKDecodeError err_var = (*val->contents.err);
5345         uint64_t err_ref = 0;
5346         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5347         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5348         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5349         err_ref = (uint64_t)err_var.inner & ~1;
5350         return err_ref;
5351 }
5352 uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
5353         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
5354         switch(obj->tag) {
5355                 case LDKSignOrCreationError_SignError: {
5356                         return 0 /* LDKSignOrCreationError - SignError */;
5357                 }
5358                 case LDKSignOrCreationError_CreationError: {
5359                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
5360                         return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
5361                 }
5362                 default: abort();
5363         }
5364 }
5365 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
5366         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5367         CHECK(val->result_ok);
5368         LDKInvoice res_var = (*val->contents.result);
5369         uint64_t res_ref = 0;
5370         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5371         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5372         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5373         res_ref = (uint64_t)res_var.inner & ~1;
5374         return res_ref;
5375 }
5376 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
5377         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
5378         CHECK(!val->result_ok);
5379         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5380         return err_ref;
5381 }
5382 typedef struct LDKFilter_JCalls {
5383         atomic_size_t refcnt;
5384         uint32_t register_tx_meth;
5385         uint32_t register_output_meth;
5386 } LDKFilter_JCalls;
5387 static void LDKFilter_JCalls_free(void* this_arg) {
5388         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5389         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5390                 js_free(j_calls->register_tx_meth);
5391                 js_free(j_calls->register_output_meth);
5392                 FREE(j_calls);
5393         }
5394 }
5395 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5396         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5397         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5398         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5399         LDKu8slice script_pubkey_var = script_pubkey;
5400         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5401         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
5402         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
5403 }
5404 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5405         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5406         LDKWatchedOutput output_var = output;
5407         uint64_t output_ref = 0;
5408         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5409         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5410         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
5411         output_ref = (uint64_t)output_var.inner;
5412         if (output_var.is_owned) {
5413                 output_ref |= 1;
5414         }
5415         uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
5416         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5417         CHECK_ACCESS(ret_ptr);
5418         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
5419         FREE((void*)ret);
5420         return ret_conv;
5421 }
5422 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5423         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5424         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5425 }
5426 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
5427         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5428         atomic_init(&calls->refcnt, 1);
5429         //TODO: Assign calls->o from o
5430
5431         LDKFilter ret = {
5432                 .this_arg = (void*) calls,
5433                 .register_tx = register_tx_LDKFilter_jcall,
5434                 .register_output = register_output_LDKFilter_jcall,
5435                 .free = LDKFilter_JCalls_free,
5436         };
5437         return ret;
5438 }
5439 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
5440         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5441         *res_ptr = LDKFilter_init(o);
5442         return (long)res_ptr;
5443 }
5444 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5445         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5446         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5447         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5448         unsigned char txid_arr[32];
5449         CHECK(*((uint32_t*)txid) == 32);
5450         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5451         unsigned char (*txid_ref)[32] = &txid_arr;
5452         LDKu8slice script_pubkey_ref;
5453         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
5454         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
5455         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5456 }
5457
5458 uint32_t  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5459         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5460         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5461         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5462         LDKWatchedOutput output_conv;
5463         output_conv.inner = (void*)(output & (~1));
5464         output_conv.is_owned = (output & 1) || (output == 0);
5465         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
5466         output_conv = WatchedOutput_clone(&output_conv);
5467         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5468         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5469         uint64_t ret_ref = (uint64_t)ret_copy;
5470         return ret_ref;
5471 }
5472
5473 uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
5474         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5475         switch(obj->tag) {
5476                 case LDKCOption_FilterZ_Some: {
5477                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
5478                         *some_ret = obj->some;
5479                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5480                         return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
5481                 }
5482                 case LDKCOption_FilterZ_None: {
5483                         return 0 /* LDKCOption_FilterZ - None */;
5484                 }
5485                 default: abort();
5486         }
5487 }
5488 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_ok(uint32_t arg) {
5489         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5490         CHECK(val->result_ok);
5491         LDKLockedChannelMonitor res_var = (*val->contents.result);
5492         uint64_t res_ref = 0;
5493         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5494         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5495         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5496         res_ref = (uint64_t)res_var.inner & ~1;
5497         return res_ref;
5498 }
5499 void  __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
5500         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
5501         CHECK(!val->result_ok);
5502         return *val->contents.err;
5503 }
5504 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5505         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5506         for (size_t i = 0; i < ret.datalen; i++) {
5507                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5508         }
5509         return ret;
5510 }
5511 typedef struct LDKMessageSendEventsProvider_JCalls {
5512         atomic_size_t refcnt;
5513         uint32_t get_and_clear_pending_msg_events_meth;
5514 } LDKMessageSendEventsProvider_JCalls;
5515 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
5516         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5517         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5518                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
5519                 FREE(j_calls);
5520         }
5521 }
5522 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
5523         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
5524         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
5525         LDKCVec_MessageSendEventZ ret_constr;
5526         ret_constr.datalen = *((uint32_t*)ret);
5527         if (ret_constr.datalen > 0)
5528                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
5529         else
5530                 ret_constr.data = NULL;
5531         uint32_t* ret_vals = (uint32_t*)(ret + 4);
5532         for (size_t s = 0; s < ret_constr.datalen; s++) {
5533                 uint32_t ret_conv_18 = ret_vals[s];
5534                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
5535                 CHECK_ACCESS(ret_conv_18_ptr);
5536                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
5537                 FREE((void*)ret_conv_18);
5538                 ret_constr.data[s] = ret_conv_18_conv;
5539         }
5540         return ret_constr;
5541 }
5542 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
5543         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
5544         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5545 }
5546 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5547         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
5548         atomic_init(&calls->refcnt, 1);
5549         //TODO: Assign calls->o from o
5550
5551         LDKMessageSendEventsProvider ret = {
5552                 .this_arg = (void*) calls,
5553                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
5554                 .free = LDKMessageSendEventsProvider_JCalls_free,
5555         };
5556         return ret;
5557 }
5558 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5559         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
5560         *res_ptr = LDKMessageSendEventsProvider_init(o);
5561         return (long)res_ptr;
5562 }
5563 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
5564         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5565         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5566         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
5567         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
5568         uint32_tArray ret_arr = NULL;
5569         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5570         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
5571         for (size_t s = 0; s < ret_var.datalen; s++) {
5572                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5573                 *ret_conv_18_copy = ret_var.data[s];
5574                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
5575                 ret_arr_ptr[s] = ret_conv_18_ref;
5576         }
5577         
5578         FREE(ret_var.data);
5579         return ret_arr;
5580 }
5581
5582 typedef struct LDKEventHandler_JCalls {
5583         atomic_size_t refcnt;
5584         uint32_t handle_event_meth;
5585 } LDKEventHandler_JCalls;
5586 static void LDKEventHandler_JCalls_free(void* this_arg) {
5587         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5588         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5589                 js_free(j_calls->handle_event_meth);
5590                 FREE(j_calls);
5591         }
5592 }
5593 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
5594         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
5595         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
5596         *ret_event = Event_clone(event);
5597         js_invoke_function_1(j_calls->handle_event_meth, (uint64_t)ret_event);
5598 }
5599 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
5600         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
5601         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5602 }
5603 static inline LDKEventHandler LDKEventHandler_init (/*TODO: JS Object Reference */void* o) {
5604         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
5605         atomic_init(&calls->refcnt, 1);
5606         //TODO: Assign calls->o from o
5607
5608         LDKEventHandler ret = {
5609                 .this_arg = (void*) calls,
5610                 .handle_event = handle_event_LDKEventHandler_jcall,
5611                 .free = LDKEventHandler_JCalls_free,
5612         };
5613         return ret;
5614 }
5615 long  __attribute__((visibility("default"))) TS_LDKEventHandler_new(/*TODO: JS Object Reference */void* o) {
5616         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5617         *res_ptr = LDKEventHandler_init(o);
5618         return (long)res_ptr;
5619 }
5620 void  __attribute__((visibility("default"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
5621         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5622         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5623         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
5624         LDKEvent* event_conv = (LDKEvent*)event;
5625         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
5626 }
5627
5628 typedef struct LDKEventsProvider_JCalls {
5629         atomic_size_t refcnt;
5630         uint32_t process_pending_events_meth;
5631 } LDKEventsProvider_JCalls;
5632 static void LDKEventsProvider_JCalls_free(void* this_arg) {
5633         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5634         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5635                 js_free(j_calls->process_pending_events_meth);
5636                 FREE(j_calls);
5637         }
5638 }
5639 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
5640         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
5641         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
5642         *handler_ret = handler;
5643         js_invoke_function_1(j_calls->process_pending_events_meth, (uint64_t)handler_ret);
5644 }
5645 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
5646         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
5647         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5648 }
5649 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
5650         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
5651         atomic_init(&calls->refcnt, 1);
5652         //TODO: Assign calls->o from o
5653
5654         LDKEventsProvider ret = {
5655                 .this_arg = (void*) calls,
5656                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
5657                 .free = LDKEventsProvider_JCalls_free,
5658         };
5659         return ret;
5660 }
5661 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
5662         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5663         *res_ptr = LDKEventsProvider_init(o);
5664         return (long)res_ptr;
5665 }
5666 void  __attribute__((visibility("default"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
5667         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5669         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
5670         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
5671         CHECK_ACCESS(handler_ptr);
5672         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
5673         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
5674 }
5675
5676 typedef struct LDKListen_JCalls {
5677         atomic_size_t refcnt;
5678         uint32_t block_connected_meth;
5679         uint32_t block_disconnected_meth;
5680 } LDKListen_JCalls;
5681 static void LDKListen_JCalls_free(void* this_arg) {
5682         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5683         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5684                 js_free(j_calls->block_connected_meth);
5685                 js_free(j_calls->block_disconnected_meth);
5686                 FREE(j_calls);
5687         }
5688 }
5689 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
5690         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5691         LDKu8slice block_var = block;
5692         int8_tArray block_arr = init_arr(block_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
5693         memcpy((uint8_t*)(block_arr + 4), block_var.data, block_var.datalen);
5694         js_invoke_function_2(j_calls->block_connected_meth, block_arr, height);
5695 }
5696 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5697         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
5698         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5699         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5700         js_invoke_function_2(j_calls->block_disconnected_meth, header_arr, height);
5701 }
5702 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
5703         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
5704         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5705 }
5706 static inline LDKListen LDKListen_init (/*TODO: JS Object Reference */void* o) {
5707         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
5708         atomic_init(&calls->refcnt, 1);
5709         //TODO: Assign calls->o from o
5710
5711         LDKListen ret = {
5712                 .this_arg = (void*) calls,
5713                 .block_connected = block_connected_LDKListen_jcall,
5714                 .block_disconnected = block_disconnected_LDKListen_jcall,
5715                 .free = LDKListen_JCalls_free,
5716         };
5717         return ret;
5718 }
5719 long  __attribute__((visibility("default"))) TS_LDKListen_new(/*TODO: JS Object Reference */void* o) {
5720         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
5721         *res_ptr = LDKListen_init(o);
5722         return (long)res_ptr;
5723 }
5724 void  __attribute__((visibility("default"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
5725         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5726         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5727         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
5728         LDKu8slice block_ref;
5729         block_ref.datalen = *((uint32_t*)block);
5730         block_ref.data = (int8_t*)(block + 4);
5731         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
5732 }
5733
5734 void  __attribute__((visibility("default"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
5735         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5736         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5737         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
5738         unsigned char header_arr[80];
5739         CHECK(*((uint32_t*)header) == 80);
5740         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5741         unsigned char (*header_ref)[80] = &header_arr;
5742         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
5743 }
5744
5745 typedef struct LDKConfirm_JCalls {
5746         atomic_size_t refcnt;
5747         uint32_t transactions_confirmed_meth;
5748         uint32_t transaction_unconfirmed_meth;
5749         uint32_t best_block_updated_meth;
5750         uint32_t get_relevant_txids_meth;
5751 } LDKConfirm_JCalls;
5752 static void LDKConfirm_JCalls_free(void* this_arg) {
5753         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5754         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5755                 js_free(j_calls->transactions_confirmed_meth);
5756                 js_free(j_calls->transaction_unconfirmed_meth);
5757                 js_free(j_calls->best_block_updated_meth);
5758                 js_free(j_calls->get_relevant_txids_meth);
5759                 FREE(j_calls);
5760         }
5761 }
5762 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
5763         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5764         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5765         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5766         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
5767         uint32_tArray txdata_arr = NULL;
5768         txdata_arr = init_arr(txdata_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
5769         uint32_t *txdata_arr_ptr = (uint32_t*)(txdata_arr + 4);
5770         for (size_t c = 0; c < txdata_var.datalen; c++) {
5771                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
5772                 *txdata_conv_28_conv = txdata_var.data[c];
5773                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
5774         }
5775         
5776         FREE(txdata_var.data);
5777         js_invoke_function_3(j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
5778 }
5779 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
5780         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5781         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5782         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
5783         js_invoke_function_1(j_calls->transaction_unconfirmed_meth, txid_arr);
5784 }
5785 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
5786         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5787         int8_tArray header_arr = init_arr(80, sizeof(uint8_t), "Native int8_tArray Bytes");
5788         memcpy((uint8_t*)(header_arr + 4), *header, 80);
5789         js_invoke_function_2(j_calls->best_block_updated_meth, header_arr, height);
5790 }
5791 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
5792         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
5793         ptrArray ret = js_invoke_function_0(j_calls->get_relevant_txids_meth);
5794         LDKCVec_TxidZ ret_constr;
5795         ret_constr.datalen = *((uint32_t*)ret);
5796         if (ret_constr.datalen > 0)
5797                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
5798         else
5799                 ret_constr.data = NULL;
5800         int8_tArray* ret_vals = (int8_tArray*)(ret + 4);
5801         for (size_t m = 0; m < ret_constr.datalen; m++) {
5802                 int8_tArray ret_conv_12 = ret_vals[m];
5803                 LDKThirtyTwoBytes ret_conv_12_ref;
5804                 CHECK(*((uint32_t*)ret_conv_12) == 32);
5805                 memcpy(ret_conv_12_ref.data, (uint8_t*)(ret_conv_12 + 4), 32);
5806                 ret_constr.data[m] = ret_conv_12_ref;
5807         }
5808         return ret_constr;
5809 }
5810 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
5811         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
5812         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5813 }
5814 static inline LDKConfirm LDKConfirm_init (/*TODO: JS Object Reference */void* o) {
5815         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
5816         atomic_init(&calls->refcnt, 1);
5817         //TODO: Assign calls->o from o
5818
5819         LDKConfirm ret = {
5820                 .this_arg = (void*) calls,
5821                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
5822                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
5823                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
5824                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
5825                 .free = LDKConfirm_JCalls_free,
5826         };
5827         return ret;
5828 }
5829 long  __attribute__((visibility("default"))) TS_LDKConfirm_new(/*TODO: JS Object Reference */void* o) {
5830         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
5831         *res_ptr = LDKConfirm_init(o);
5832         return (long)res_ptr;
5833 }
5834 void  __attribute__((visibility("default"))) TS_Confirm_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5835         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5836         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5837         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5838         unsigned char header_arr[80];
5839         CHECK(*((uint32_t*)header) == 80);
5840         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5841         unsigned char (*header_ref)[80] = &header_arr;
5842         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5843         txdata_constr.datalen = *((uint32_t*)txdata);
5844         if (txdata_constr.datalen > 0)
5845                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5846         else
5847                 txdata_constr.data = NULL;
5848         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
5849         for (size_t c = 0; c < txdata_constr.datalen; c++) {
5850                 uint32_t txdata_conv_28 = txdata_vals[c];
5851                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
5852                 CHECK_ACCESS(txdata_conv_28_ptr);
5853                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
5854                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
5855                 txdata_constr.data[c] = txdata_conv_28_conv;
5856         }
5857         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
5858 }
5859
5860 void  __attribute__((visibility("default"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
5861         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5862         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5863         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5864         unsigned char txid_arr[32];
5865         CHECK(*((uint32_t*)txid) == 32);
5866         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
5867         unsigned char (*txid_ref)[32] = &txid_arr;
5868         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
5869 }
5870
5871 void  __attribute__((visibility("default"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
5872         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5873         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5874         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5875         unsigned char header_arr[80];
5876         CHECK(*((uint32_t*)header) == 80);
5877         memcpy(header_arr, (uint8_t*)(header + 4), 80);
5878         unsigned char (*header_ref)[80] = &header_arr;
5879         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
5880 }
5881
5882 ptrArray  __attribute__((visibility("default"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
5883         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5884         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5885         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
5886         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
5887         ptrArray ret_arr = NULL;
5888         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
5889         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
5890         for (size_t m = 0; m < ret_var.datalen; m++) {
5891                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
5892                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
5893                 ret_arr_ptr[m] = ret_conv_12_arr;
5894         }
5895         
5896         FREE(ret_var.data);
5897         return ret_arr;
5898 }
5899
5900 typedef struct LDKPersist_JCalls {
5901         atomic_size_t refcnt;
5902         uint32_t persist_new_channel_meth;
5903         uint32_t update_persisted_channel_meth;
5904 } LDKPersist_JCalls;
5905 static void LDKPersist_JCalls_free(void* this_arg) {
5906         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5907         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5908                 js_free(j_calls->persist_new_channel_meth);
5909                 js_free(j_calls->update_persisted_channel_meth);
5910                 FREE(j_calls);
5911         }
5912 }
5913 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
5914         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5915         LDKOutPoint channel_id_var = channel_id;
5916         uint64_t channel_id_ref = 0;
5917         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5918         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5919         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
5920         channel_id_ref = (uint64_t)channel_id_var.inner;
5921         if (channel_id_var.is_owned) {
5922                 channel_id_ref |= 1;
5923         }
5924         LDKChannelMonitor data_var = *data;
5925         uint64_t data_ref = 0;
5926         data_var = ChannelMonitor_clone(data);
5927         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5928         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5929         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
5930         data_ref = (uint64_t)data_var.inner;
5931         if (data_var.is_owned) {
5932                 data_ref |= 1;
5933         }
5934         LDKMonitorUpdateId update_id_var = update_id;
5935         uint64_t update_id_ref = 0;
5936         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5937         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5938         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
5939         update_id_ref = (uint64_t)update_id_var.inner;
5940         if (update_id_var.is_owned) {
5941                 update_id_ref |= 1;
5942         }
5943         uint32_t ret = js_invoke_function_3(j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
5944         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5945         CHECK_ACCESS(ret_ptr);
5946         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5947         FREE((void*)ret);
5948         return ret_conv;
5949 }
5950 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
5951         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
5952         LDKOutPoint channel_id_var = channel_id;
5953         uint64_t channel_id_ref = 0;
5954         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5955         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5956         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
5957         channel_id_ref = (uint64_t)channel_id_var.inner;
5958         if (channel_id_var.is_owned) {
5959                 channel_id_ref |= 1;
5960         }
5961         LDKChannelMonitorUpdate update_var = *update;
5962         uint64_t update_ref = 0;
5963         if ((uint64_t)update_var.inner > 4096) {
5964                 update_var = ChannelMonitorUpdate_clone(update);
5965                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5966                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5967         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5968                 update_ref = (uint64_t)update_var.inner;
5969                 if (update_var.is_owned) {
5970                         update_ref |= 1;
5971                 }
5972         }
5973         LDKChannelMonitor data_var = *data;
5974         uint64_t data_ref = 0;
5975         data_var = ChannelMonitor_clone(data);
5976         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5977         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5978         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
5979         data_ref = (uint64_t)data_var.inner;
5980         if (data_var.is_owned) {
5981                 data_ref |= 1;
5982         }
5983         LDKMonitorUpdateId update_id_var = update_id;
5984         uint64_t update_id_ref = 0;
5985         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5986         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5987         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
5988         update_id_ref = (uint64_t)update_id_var.inner;
5989         if (update_id_var.is_owned) {
5990                 update_id_ref |= 1;
5991         }
5992         uint32_t ret = js_invoke_function_4(j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
5993         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
5994         CHECK_ACCESS(ret_ptr);
5995         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5996         FREE((void*)ret);
5997         return ret_conv;
5998 }
5999 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
6000         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
6001         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6002 }
6003 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
6004         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
6005         atomic_init(&calls->refcnt, 1);
6006         //TODO: Assign calls->o from o
6007
6008         LDKPersist ret = {
6009                 .this_arg = (void*) calls,
6010                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
6011                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
6012                 .free = LDKPersist_JCalls_free,
6013         };
6014         return ret;
6015 }
6016 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
6017         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
6018         *res_ptr = LDKPersist_init(o);
6019         return (long)res_ptr;
6020 }
6021 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t channel_id, uint32_t data, uint32_t update_id) {
6022         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6023         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6024         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
6025         LDKOutPoint channel_id_conv;
6026         channel_id_conv.inner = (void*)(channel_id & (~1));
6027         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
6028         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
6029         channel_id_conv = OutPoint_clone(&channel_id_conv);
6030         LDKChannelMonitor data_conv;
6031         data_conv.inner = (void*)(data & (~1));
6032         data_conv.is_owned = false;
6033         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
6034         LDKMonitorUpdateId update_id_conv;
6035         update_id_conv.inner = (void*)(update_id & (~1));
6036         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
6037         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
6038         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
6039         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6040         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
6041         return (uint64_t)ret_conv;
6042 }
6043
6044 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t channel_id, uint32_t update, uint32_t data, uint32_t update_id) {
6045         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6046         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6047         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
6048         LDKOutPoint channel_id_conv;
6049         channel_id_conv.inner = (void*)(channel_id & (~1));
6050         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
6051         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
6052         channel_id_conv = OutPoint_clone(&channel_id_conv);
6053         LDKChannelMonitorUpdate update_conv;
6054         update_conv.inner = (void*)(update & (~1));
6055         update_conv.is_owned = false;
6056         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6057         LDKChannelMonitor data_conv;
6058         data_conv.inner = (void*)(data & (~1));
6059         data_conv.is_owned = false;
6060         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
6061         LDKMonitorUpdateId update_id_conv;
6062         update_id_conv.inner = (void*)(update_id & (~1));
6063         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
6064         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
6065         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
6066         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6067         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
6068         return (uint64_t)ret_conv;
6069 }
6070
6071 typedef struct LDKChannelMessageHandler_JCalls {
6072         atomic_size_t refcnt;
6073         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6074         uint32_t handle_open_channel_meth;
6075         uint32_t handle_accept_channel_meth;
6076         uint32_t handle_funding_created_meth;
6077         uint32_t handle_funding_signed_meth;
6078         uint32_t handle_funding_locked_meth;
6079         uint32_t handle_shutdown_meth;
6080         uint32_t handle_closing_signed_meth;
6081         uint32_t handle_update_add_htlc_meth;
6082         uint32_t handle_update_fulfill_htlc_meth;
6083         uint32_t handle_update_fail_htlc_meth;
6084         uint32_t handle_update_fail_malformed_htlc_meth;
6085         uint32_t handle_commitment_signed_meth;
6086         uint32_t handle_revoke_and_ack_meth;
6087         uint32_t handle_update_fee_meth;
6088         uint32_t handle_announcement_signatures_meth;
6089         uint32_t peer_disconnected_meth;
6090         uint32_t peer_connected_meth;
6091         uint32_t handle_channel_reestablish_meth;
6092         uint32_t handle_channel_update_meth;
6093         uint32_t handle_error_meth;
6094 } LDKChannelMessageHandler_JCalls;
6095 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
6096         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6097         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6098                 js_free(j_calls->handle_open_channel_meth);
6099                 js_free(j_calls->handle_accept_channel_meth);
6100                 js_free(j_calls->handle_funding_created_meth);
6101                 js_free(j_calls->handle_funding_signed_meth);
6102                 js_free(j_calls->handle_funding_locked_meth);
6103                 js_free(j_calls->handle_shutdown_meth);
6104                 js_free(j_calls->handle_closing_signed_meth);
6105                 js_free(j_calls->handle_update_add_htlc_meth);
6106                 js_free(j_calls->handle_update_fulfill_htlc_meth);
6107                 js_free(j_calls->handle_update_fail_htlc_meth);
6108                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
6109                 js_free(j_calls->handle_commitment_signed_meth);
6110                 js_free(j_calls->handle_revoke_and_ack_meth);
6111                 js_free(j_calls->handle_update_fee_meth);
6112                 js_free(j_calls->handle_announcement_signatures_meth);
6113                 js_free(j_calls->peer_disconnected_meth);
6114                 js_free(j_calls->peer_connected_meth);
6115                 js_free(j_calls->handle_channel_reestablish_meth);
6116                 js_free(j_calls->handle_channel_update_meth);
6117                 js_free(j_calls->handle_error_meth);
6118                 FREE(j_calls);
6119         }
6120 }
6121 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
6122         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6123         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6124         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6125         LDKInitFeatures their_features_var = their_features;
6126         uint64_t their_features_ref = 0;
6127         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6128         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6129         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
6130         their_features_ref = (uint64_t)their_features_var.inner;
6131         if (their_features_var.is_owned) {
6132                 their_features_ref |= 1;
6133         }
6134         LDKOpenChannel msg_var = *msg;
6135         uint64_t msg_ref = 0;
6136         msg_var = OpenChannel_clone(msg);
6137         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6138         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6139         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6140         msg_ref = (uint64_t)msg_var.inner;
6141         if (msg_var.is_owned) {
6142                 msg_ref |= 1;
6143         }
6144         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6145 }
6146 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
6147         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6148         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6149         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6150         LDKInitFeatures their_features_var = their_features;
6151         uint64_t their_features_ref = 0;
6152         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6153         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6154         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
6155         their_features_ref = (uint64_t)their_features_var.inner;
6156         if (their_features_var.is_owned) {
6157                 their_features_ref |= 1;
6158         }
6159         LDKAcceptChannel msg_var = *msg;
6160         uint64_t msg_ref = 0;
6161         msg_var = AcceptChannel_clone(msg);
6162         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6163         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6164         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6165         msg_ref = (uint64_t)msg_var.inner;
6166         if (msg_var.is_owned) {
6167                 msg_ref |= 1;
6168         }
6169         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
6170 }
6171 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
6172         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6173         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6174         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6175         LDKFundingCreated msg_var = *msg;
6176         uint64_t msg_ref = 0;
6177         msg_var = FundingCreated_clone(msg);
6178         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6179         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6180         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6181         msg_ref = (uint64_t)msg_var.inner;
6182         if (msg_var.is_owned) {
6183                 msg_ref |= 1;
6184         }
6185         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
6186 }
6187 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
6188         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6189         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6190         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6191         LDKFundingSigned msg_var = *msg;
6192         uint64_t msg_ref = 0;
6193         msg_var = FundingSigned_clone(msg);
6194         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6195         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6196         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6197         msg_ref = (uint64_t)msg_var.inner;
6198         if (msg_var.is_owned) {
6199                 msg_ref |= 1;
6200         }
6201         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
6202 }
6203 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
6204         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6205         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6206         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6207         LDKFundingLocked msg_var = *msg;
6208         uint64_t msg_ref = 0;
6209         msg_var = FundingLocked_clone(msg);
6210         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6211         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6212         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6213         msg_ref = (uint64_t)msg_var.inner;
6214         if (msg_var.is_owned) {
6215                 msg_ref |= 1;
6216         }
6217         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
6218 }
6219 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
6220         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6221         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6222         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6223         LDKInitFeatures their_features_var = *their_features;
6224         uint64_t their_features_ref = 0;
6225         their_features_var = InitFeatures_clone(their_features);
6226         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6227         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6228         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
6229         their_features_ref = (uint64_t)their_features_var.inner;
6230         if (their_features_var.is_owned) {
6231                 their_features_ref |= 1;
6232         }
6233         LDKShutdown msg_var = *msg;
6234         uint64_t msg_ref = 0;
6235         msg_var = Shutdown_clone(msg);
6236         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6237         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6238         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6239         msg_ref = (uint64_t)msg_var.inner;
6240         if (msg_var.is_owned) {
6241                 msg_ref |= 1;
6242         }
6243         js_invoke_function_3(j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
6244 }
6245 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
6246         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6247         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6248         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6249         LDKClosingSigned msg_var = *msg;
6250         uint64_t msg_ref = 0;
6251         msg_var = ClosingSigned_clone(msg);
6252         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6253         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6254         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6255         msg_ref = (uint64_t)msg_var.inner;
6256         if (msg_var.is_owned) {
6257                 msg_ref |= 1;
6258         }
6259         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
6260 }
6261 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
6262         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6263         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6264         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6265         LDKUpdateAddHTLC msg_var = *msg;
6266         uint64_t msg_ref = 0;
6267         msg_var = UpdateAddHTLC_clone(msg);
6268         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6269         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6270         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6271         msg_ref = (uint64_t)msg_var.inner;
6272         if (msg_var.is_owned) {
6273                 msg_ref |= 1;
6274         }
6275         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
6276 }
6277 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
6278         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6279         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6280         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6281         LDKUpdateFulfillHTLC msg_var = *msg;
6282         uint64_t msg_ref = 0;
6283         msg_var = UpdateFulfillHTLC_clone(msg);
6284         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6285         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6286         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6287         msg_ref = (uint64_t)msg_var.inner;
6288         if (msg_var.is_owned) {
6289                 msg_ref |= 1;
6290         }
6291         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
6292 }
6293 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
6294         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6295         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6296         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6297         LDKUpdateFailHTLC msg_var = *msg;
6298         uint64_t msg_ref = 0;
6299         msg_var = UpdateFailHTLC_clone(msg);
6300         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6301         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6303         msg_ref = (uint64_t)msg_var.inner;
6304         if (msg_var.is_owned) {
6305                 msg_ref |= 1;
6306         }
6307         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
6308 }
6309 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
6310         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6311         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6312         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6313         LDKUpdateFailMalformedHTLC msg_var = *msg;
6314         uint64_t msg_ref = 0;
6315         msg_var = UpdateFailMalformedHTLC_clone(msg);
6316         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6317         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6318         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6319         msg_ref = (uint64_t)msg_var.inner;
6320         if (msg_var.is_owned) {
6321                 msg_ref |= 1;
6322         }
6323         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
6324 }
6325 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
6326         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6327         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6328         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6329         LDKCommitmentSigned msg_var = *msg;
6330         uint64_t msg_ref = 0;
6331         msg_var = CommitmentSigned_clone(msg);
6332         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6333         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6334         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6335         msg_ref = (uint64_t)msg_var.inner;
6336         if (msg_var.is_owned) {
6337                 msg_ref |= 1;
6338         }
6339         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
6340 }
6341 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
6342         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6343         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6344         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6345         LDKRevokeAndACK msg_var = *msg;
6346         uint64_t msg_ref = 0;
6347         msg_var = RevokeAndACK_clone(msg);
6348         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6349         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6350         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6351         msg_ref = (uint64_t)msg_var.inner;
6352         if (msg_var.is_owned) {
6353                 msg_ref |= 1;
6354         }
6355         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
6356 }
6357 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
6358         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6359         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6360         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6361         LDKUpdateFee msg_var = *msg;
6362         uint64_t msg_ref = 0;
6363         msg_var = UpdateFee_clone(msg);
6364         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6365         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6366         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6367         msg_ref = (uint64_t)msg_var.inner;
6368         if (msg_var.is_owned) {
6369                 msg_ref |= 1;
6370         }
6371         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
6372 }
6373 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
6374         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6375         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6376         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6377         LDKAnnouncementSignatures msg_var = *msg;
6378         uint64_t msg_ref = 0;
6379         msg_var = AnnouncementSignatures_clone(msg);
6380         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6381         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6382         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6383         msg_ref = (uint64_t)msg_var.inner;
6384         if (msg_var.is_owned) {
6385                 msg_ref |= 1;
6386         }
6387         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
6388 }
6389 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
6390         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6391         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6392         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6393         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
6394 }
6395 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
6396         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6397         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6398         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6399         LDKInit msg_var = *msg;
6400         uint64_t msg_ref = 0;
6401         msg_var = Init_clone(msg);
6402         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6403         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6404         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6405         msg_ref = (uint64_t)msg_var.inner;
6406         if (msg_var.is_owned) {
6407                 msg_ref |= 1;
6408         }
6409         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
6410 }
6411 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
6412         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6413         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6414         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6415         LDKChannelReestablish msg_var = *msg;
6416         uint64_t msg_ref = 0;
6417         msg_var = ChannelReestablish_clone(msg);
6418         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6419         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6420         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6421         msg_ref = (uint64_t)msg_var.inner;
6422         if (msg_var.is_owned) {
6423                 msg_ref |= 1;
6424         }
6425         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
6426 }
6427 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
6428         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6429         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6430         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6431         LDKChannelUpdate msg_var = *msg;
6432         uint64_t msg_ref = 0;
6433         msg_var = ChannelUpdate_clone(msg);
6434         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6435         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6436         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6437         msg_ref = (uint64_t)msg_var.inner;
6438         if (msg_var.is_owned) {
6439                 msg_ref |= 1;
6440         }
6441         js_invoke_function_2(j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
6442 }
6443 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
6444         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
6445         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6446         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6447         LDKErrorMessage msg_var = *msg;
6448         uint64_t msg_ref = 0;
6449         msg_var = ErrorMessage_clone(msg);
6450         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6451         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6452         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6453         msg_ref = (uint64_t)msg_var.inner;
6454         if (msg_var.is_owned) {
6455                 msg_ref |= 1;
6456         }
6457         js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
6458 }
6459 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
6460         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
6461         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6462         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
6463 }
6464 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
6465         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
6466         atomic_init(&calls->refcnt, 1);
6467         //TODO: Assign calls->o from o
6468
6469         LDKChannelMessageHandler ret = {
6470                 .this_arg = (void*) calls,
6471                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
6472                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
6473                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
6474                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
6475                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
6476                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
6477                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
6478                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
6479                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
6480                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
6481                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
6482                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
6483                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
6484                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
6485                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
6486                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
6487                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
6488                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
6489                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
6490                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
6491                 .free = LDKChannelMessageHandler_JCalls_free,
6492                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
6493         };
6494         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
6495         return ret;
6496 }
6497 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
6498         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6499         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
6500         return (long)res_ptr;
6501 }
6502 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6503         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6504         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6505         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6506         LDKPublicKey their_node_id_ref;
6507         CHECK(*((uint32_t*)their_node_id) == 33);
6508         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6509         LDKInitFeatures their_features_conv;
6510         their_features_conv.inner = (void*)(their_features & (~1));
6511         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6512         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
6513         their_features_conv = InitFeatures_clone(&their_features_conv);
6514         LDKOpenChannel msg_conv;
6515         msg_conv.inner = (void*)(msg & (~1));
6516         msg_conv.is_owned = false;
6517         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6518         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6519 }
6520
6521 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6522         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6523         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6524         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6525         LDKPublicKey their_node_id_ref;
6526         CHECK(*((uint32_t*)their_node_id) == 33);
6527         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6528         LDKInitFeatures their_features_conv;
6529         their_features_conv.inner = (void*)(their_features & (~1));
6530         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
6531         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
6532         their_features_conv = InitFeatures_clone(&their_features_conv);
6533         LDKAcceptChannel msg_conv;
6534         msg_conv.inner = (void*)(msg & (~1));
6535         msg_conv.is_owned = false;
6536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6537         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
6538 }
6539
6540 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6541         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6542         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6543         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6544         LDKPublicKey their_node_id_ref;
6545         CHECK(*((uint32_t*)their_node_id) == 33);
6546         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6547         LDKFundingCreated msg_conv;
6548         msg_conv.inner = (void*)(msg & (~1));
6549         msg_conv.is_owned = false;
6550         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6551         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6552 }
6553
6554 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6555         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6556         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6557         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6558         LDKPublicKey their_node_id_ref;
6559         CHECK(*((uint32_t*)their_node_id) == 33);
6560         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6561         LDKFundingSigned msg_conv;
6562         msg_conv.inner = (void*)(msg & (~1));
6563         msg_conv.is_owned = false;
6564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6565         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6566 }
6567
6568 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6569         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6570         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6571         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6572         LDKPublicKey their_node_id_ref;
6573         CHECK(*((uint32_t*)their_node_id) == 33);
6574         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6575         LDKFundingLocked msg_conv;
6576         msg_conv.inner = (void*)(msg & (~1));
6577         msg_conv.is_owned = false;
6578         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6579         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6580 }
6581
6582 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
6583         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6584         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6585         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6586         LDKPublicKey their_node_id_ref;
6587         CHECK(*((uint32_t*)their_node_id) == 33);
6588         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6589         LDKInitFeatures their_features_conv;
6590         their_features_conv.inner = (void*)(their_features & (~1));
6591         their_features_conv.is_owned = false;
6592         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
6593         LDKShutdown msg_conv;
6594         msg_conv.inner = (void*)(msg & (~1));
6595         msg_conv.is_owned = false;
6596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6597         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
6598 }
6599
6600 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6601         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6602         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6603         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6604         LDKPublicKey their_node_id_ref;
6605         CHECK(*((uint32_t*)their_node_id) == 33);
6606         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6607         LDKClosingSigned msg_conv;
6608         msg_conv.inner = (void*)(msg & (~1));
6609         msg_conv.is_owned = false;
6610         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6611         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6612 }
6613
6614 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6615         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6616         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6617         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6618         LDKPublicKey their_node_id_ref;
6619         CHECK(*((uint32_t*)their_node_id) == 33);
6620         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6621         LDKUpdateAddHTLC msg_conv;
6622         msg_conv.inner = (void*)(msg & (~1));
6623         msg_conv.is_owned = false;
6624         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6625         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6626 }
6627
6628 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6629         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6630         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6631         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6632         LDKPublicKey their_node_id_ref;
6633         CHECK(*((uint32_t*)their_node_id) == 33);
6634         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6635         LDKUpdateFulfillHTLC msg_conv;
6636         msg_conv.inner = (void*)(msg & (~1));
6637         msg_conv.is_owned = false;
6638         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6639         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6640 }
6641
6642 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6643         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6644         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6645         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6646         LDKPublicKey their_node_id_ref;
6647         CHECK(*((uint32_t*)their_node_id) == 33);
6648         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6649         LDKUpdateFailHTLC msg_conv;
6650         msg_conv.inner = (void*)(msg & (~1));
6651         msg_conv.is_owned = false;
6652         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6653         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6654 }
6655
6656 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6657         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6658         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6659         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6660         LDKPublicKey their_node_id_ref;
6661         CHECK(*((uint32_t*)their_node_id) == 33);
6662         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6663         LDKUpdateFailMalformedHTLC msg_conv;
6664         msg_conv.inner = (void*)(msg & (~1));
6665         msg_conv.is_owned = false;
6666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6667         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6668 }
6669
6670 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6671         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6672         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6673         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6674         LDKPublicKey their_node_id_ref;
6675         CHECK(*((uint32_t*)their_node_id) == 33);
6676         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6677         LDKCommitmentSigned msg_conv;
6678         msg_conv.inner = (void*)(msg & (~1));
6679         msg_conv.is_owned = false;
6680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6681         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6682 }
6683
6684 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6685         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6686         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6687         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6688         LDKPublicKey their_node_id_ref;
6689         CHECK(*((uint32_t*)their_node_id) == 33);
6690         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6691         LDKRevokeAndACK msg_conv;
6692         msg_conv.inner = (void*)(msg & (~1));
6693         msg_conv.is_owned = false;
6694         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6695         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6696 }
6697
6698 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6699         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6700         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6701         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6702         LDKPublicKey their_node_id_ref;
6703         CHECK(*((uint32_t*)their_node_id) == 33);
6704         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6705         LDKUpdateFee msg_conv;
6706         msg_conv.inner = (void*)(msg & (~1));
6707         msg_conv.is_owned = false;
6708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6709         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6710 }
6711
6712 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6713         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6714         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6715         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6716         LDKPublicKey their_node_id_ref;
6717         CHECK(*((uint32_t*)their_node_id) == 33);
6718         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6719         LDKAnnouncementSignatures msg_conv;
6720         msg_conv.inner = (void*)(msg & (~1));
6721         msg_conv.is_owned = false;
6722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6723         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6724 }
6725
6726 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
6727         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6728         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6729         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6730         LDKPublicKey their_node_id_ref;
6731         CHECK(*((uint32_t*)their_node_id) == 33);
6732         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6733         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
6734 }
6735
6736 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6737         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6738         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6739         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6740         LDKPublicKey their_node_id_ref;
6741         CHECK(*((uint32_t*)their_node_id) == 33);
6742         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6743         LDKInit msg_conv;
6744         msg_conv.inner = (void*)(msg & (~1));
6745         msg_conv.is_owned = false;
6746         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6747         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6748 }
6749
6750 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6751         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6752         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6753         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6754         LDKPublicKey their_node_id_ref;
6755         CHECK(*((uint32_t*)their_node_id) == 33);
6756         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6757         LDKChannelReestablish msg_conv;
6758         msg_conv.inner = (void*)(msg & (~1));
6759         msg_conv.is_owned = false;
6760         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6761         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6762 }
6763
6764 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_update(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6765         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6767         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6768         LDKPublicKey their_node_id_ref;
6769         CHECK(*((uint32_t*)their_node_id) == 33);
6770         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6771         LDKChannelUpdate msg_conv;
6772         msg_conv.inner = (void*)(msg & (~1));
6773         msg_conv.is_owned = false;
6774         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6775         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6776 }
6777
6778 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
6779         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6780         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6781         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
6782         LDKPublicKey their_node_id_ref;
6783         CHECK(*((uint32_t*)their_node_id) == 33);
6784         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
6785         LDKErrorMessage msg_conv;
6786         msg_conv.inner = (void*)(msg & (~1));
6787         msg_conv.is_owned = false;
6788         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6789         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
6790 }
6791
6792 typedef struct LDKRoutingMessageHandler_JCalls {
6793         atomic_size_t refcnt;
6794         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
6795         uint32_t handle_node_announcement_meth;
6796         uint32_t handle_channel_announcement_meth;
6797         uint32_t handle_channel_update_meth;
6798         uint32_t get_next_channel_announcements_meth;
6799         uint32_t get_next_node_announcements_meth;
6800         uint32_t sync_routing_table_meth;
6801         uint32_t handle_reply_channel_range_meth;
6802         uint32_t handle_reply_short_channel_ids_end_meth;
6803         uint32_t handle_query_channel_range_meth;
6804         uint32_t handle_query_short_channel_ids_meth;
6805 } LDKRoutingMessageHandler_JCalls;
6806 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
6807         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6808         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6809                 js_free(j_calls->handle_node_announcement_meth);
6810                 js_free(j_calls->handle_channel_announcement_meth);
6811                 js_free(j_calls->handle_channel_update_meth);
6812                 js_free(j_calls->get_next_channel_announcements_meth);
6813                 js_free(j_calls->get_next_node_announcements_meth);
6814                 js_free(j_calls->sync_routing_table_meth);
6815                 js_free(j_calls->handle_reply_channel_range_meth);
6816                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
6817                 js_free(j_calls->handle_query_channel_range_meth);
6818                 js_free(j_calls->handle_query_short_channel_ids_meth);
6819                 FREE(j_calls);
6820         }
6821 }
6822 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
6823         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6824         LDKNodeAnnouncement msg_var = *msg;
6825         uint64_t msg_ref = 0;
6826         msg_var = NodeAnnouncement_clone(msg);
6827         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6828         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6829         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6830         msg_ref = (uint64_t)msg_var.inner;
6831         if (msg_var.is_owned) {
6832                 msg_ref |= 1;
6833         }
6834         uint32_t ret = js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
6835         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6836         CHECK_ACCESS(ret_ptr);
6837         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
6838         FREE((void*)ret);
6839         return ret_conv;
6840 }
6841 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
6842         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6843         LDKChannelAnnouncement msg_var = *msg;
6844         uint64_t msg_ref = 0;
6845         msg_var = ChannelAnnouncement_clone(msg);
6846         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6847         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6848         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6849         msg_ref = (uint64_t)msg_var.inner;
6850         if (msg_var.is_owned) {
6851                 msg_ref |= 1;
6852         }
6853         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
6854         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6855         CHECK_ACCESS(ret_ptr);
6856         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
6857         FREE((void*)ret);
6858         return ret_conv;
6859 }
6860 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
6861         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6862         LDKChannelUpdate msg_var = *msg;
6863         uint64_t msg_ref = 0;
6864         msg_var = ChannelUpdate_clone(msg);
6865         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6866         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6867         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6868         msg_ref = (uint64_t)msg_var.inner;
6869         if (msg_var.is_owned) {
6870                 msg_ref |= 1;
6871         }
6872         uint32_t ret = js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
6873         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6874         CHECK_ACCESS(ret_ptr);
6875         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
6876         FREE((void*)ret);
6877         return ret_conv;
6878 }
6879 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
6880         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6881         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
6882         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
6883         ret_constr.datalen = *((uint32_t*)ret);
6884         if (ret_constr.datalen > 0)
6885                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
6886         else
6887                 ret_constr.data = NULL;
6888         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6889         for (size_t h = 0; h < ret_constr.datalen; h++) {
6890                 uint32_t ret_conv_59 = ret_vals[h];
6891                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
6892                 CHECK_ACCESS(ret_conv_59_ptr);
6893                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
6894                 FREE((void*)ret_conv_59);
6895                 ret_constr.data[h] = ret_conv_59_conv;
6896         }
6897         return ret_constr;
6898 }
6899 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
6900         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6901         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6902         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
6903         uint32_tArray ret = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
6904         LDKCVec_NodeAnnouncementZ ret_constr;
6905         ret_constr.datalen = *((uint32_t*)ret);
6906         if (ret_constr.datalen > 0)
6907                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
6908         else
6909                 ret_constr.data = NULL;
6910         uint32_t* ret_vals = (uint32_t*)(ret + 4);
6911         for (size_t s = 0; s < ret_constr.datalen; s++) {
6912                 uint32_t ret_conv_18 = ret_vals[s];
6913                 LDKNodeAnnouncement ret_conv_18_conv;
6914                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
6915                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
6916                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
6917                 ret_constr.data[s] = ret_conv_18_conv;
6918         }
6919         return ret_constr;
6920 }
6921 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
6922         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6923         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6924         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6925         LDKInit init_var = *init;
6926         uint64_t init_ref = 0;
6927         init_var = Init_clone(init);
6928         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6929         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6930         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
6931         init_ref = (uint64_t)init_var.inner;
6932         if (init_var.is_owned) {
6933                 init_ref |= 1;
6934         }
6935         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
6936 }
6937 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
6938         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6939         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6940         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6941         LDKReplyChannelRange msg_var = msg;
6942         uint64_t msg_ref = 0;
6943         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6944         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6945         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6946         msg_ref = (uint64_t)msg_var.inner;
6947         if (msg_var.is_owned) {
6948                 msg_ref |= 1;
6949         }
6950         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
6951         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6952         CHECK_ACCESS(ret_ptr);
6953         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6954         FREE((void*)ret);
6955         return ret_conv;
6956 }
6957 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
6958         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6959         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6960         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6961         LDKReplyShortChannelIdsEnd msg_var = msg;
6962         uint64_t msg_ref = 0;
6963         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6964         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6966         msg_ref = (uint64_t)msg_var.inner;
6967         if (msg_var.is_owned) {
6968                 msg_ref |= 1;
6969         }
6970         uint32_t ret = js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
6971         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6972         CHECK_ACCESS(ret_ptr);
6973         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6974         FREE((void*)ret);
6975         return ret_conv;
6976 }
6977 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
6978         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6979         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
6980         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
6981         LDKQueryChannelRange msg_var = msg;
6982         uint64_t msg_ref = 0;
6983         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6984         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6985         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
6986         msg_ref = (uint64_t)msg_var.inner;
6987         if (msg_var.is_owned) {
6988                 msg_ref |= 1;
6989         }
6990         uint32_t ret = js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
6991         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6992         CHECK_ACCESS(ret_ptr);
6993         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
6994         FREE((void*)ret);
6995         return ret_conv;
6996 }
6997 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
6998         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
6999         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7000         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
7001         LDKQueryShortChannelIds msg_var = msg;
7002         uint64_t msg_ref = 0;
7003         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7004         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7005         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7006         msg_ref = (uint64_t)msg_var.inner;
7007         if (msg_var.is_owned) {
7008                 msg_ref |= 1;
7009         }
7010         uint32_t ret = js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
7011         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7012         CHECK_ACCESS(ret_ptr);
7013         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7014         FREE((void*)ret);
7015         return ret_conv;
7016 }
7017 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
7018         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
7019         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7020         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7021 }
7022 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
7023         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
7024         atomic_init(&calls->refcnt, 1);
7025         //TODO: Assign calls->o from o
7026
7027         LDKRoutingMessageHandler ret = {
7028                 .this_arg = (void*) calls,
7029                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
7030                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
7031                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
7032                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
7033                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
7034                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
7035                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
7036                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
7037                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
7038                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
7039                 .free = LDKRoutingMessageHandler_JCalls_free,
7040                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
7041         };
7042         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7043         return ret;
7044 }
7045 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
7046         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
7047         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
7048         return (long)res_ptr;
7049 }
7050 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
7051         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7052         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7053         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7054         LDKNodeAnnouncement msg_conv;
7055         msg_conv.inner = (void*)(msg & (~1));
7056         msg_conv.is_owned = false;
7057         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7058         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7059         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
7060         return (uint64_t)ret_conv;
7061 }
7062
7063 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
7064         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7065         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7066         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7067         LDKChannelAnnouncement msg_conv;
7068         msg_conv.inner = (void*)(msg & (~1));
7069         msg_conv.is_owned = false;
7070         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7071         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7072         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
7073         return (uint64_t)ret_conv;
7074 }
7075
7076 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
7077         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7078         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7079         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7080         LDKChannelUpdate msg_conv;
7081         msg_conv.inner = (void*)(msg & (~1));
7082         msg_conv.is_owned = false;
7083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7084         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
7085         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
7086         return (uint64_t)ret_conv;
7087 }
7088
7089 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
7090         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7091         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7092         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7093         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
7094         uint32_tArray ret_arr = NULL;
7095         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7096         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7097         for (size_t h = 0; h < ret_var.datalen; h++) {
7098                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
7099                 *ret_conv_59_conv = ret_var.data[h];
7100                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
7101         }
7102         
7103         FREE(ret_var.data);
7104         return ret_arr;
7105 }
7106
7107 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
7108         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7109         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7110         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7111         LDKPublicKey starting_point_ref;
7112         CHECK(*((uint32_t*)starting_point) == 33);
7113         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
7114         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
7115         uint32_tArray ret_arr = NULL;
7116         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7117         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7118         for (size_t s = 0; s < ret_var.datalen; s++) {
7119                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
7120                 uint64_t ret_conv_18_ref = 0;
7121                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7122                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7123                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
7124                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
7125                 if (ret_conv_18_var.is_owned) {
7126                         ret_conv_18_ref |= 1;
7127                 }
7128                 ret_arr_ptr[s] = ret_conv_18_ref;
7129         }
7130         
7131         FREE(ret_var.data);
7132         return ret_arr;
7133 }
7134
7135 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
7136         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7137         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7138         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7139         LDKPublicKey their_node_id_ref;
7140         CHECK(*((uint32_t*)their_node_id) == 33);
7141         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7142         LDKInit init_conv;
7143         init_conv.inner = (void*)(init & (~1));
7144         init_conv.is_owned = false;
7145         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
7146         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
7147 }
7148
7149 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7150         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7151         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7152         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7153         LDKPublicKey their_node_id_ref;
7154         CHECK(*((uint32_t*)their_node_id) == 33);
7155         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7156         LDKReplyChannelRange msg_conv;
7157         msg_conv.inner = (void*)(msg & (~1));
7158         msg_conv.is_owned = (msg & 1) || (msg == 0);
7159         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7160         msg_conv = ReplyChannelRange_clone(&msg_conv);
7161         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7162         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7163         return (uint64_t)ret_conv;
7164 }
7165
7166 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7167         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7169         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7170         LDKPublicKey their_node_id_ref;
7171         CHECK(*((uint32_t*)their_node_id) == 33);
7172         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7173         LDKReplyShortChannelIdsEnd msg_conv;
7174         msg_conv.inner = (void*)(msg & (~1));
7175         msg_conv.is_owned = (msg & 1) || (msg == 0);
7176         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7177         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
7178         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7179         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7180         return (uint64_t)ret_conv;
7181 }
7182
7183 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7184         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7185         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7186         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7187         LDKPublicKey their_node_id_ref;
7188         CHECK(*((uint32_t*)their_node_id) == 33);
7189         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7190         LDKQueryChannelRange msg_conv;
7191         msg_conv.inner = (void*)(msg & (~1));
7192         msg_conv.is_owned = (msg & 1) || (msg == 0);
7193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7194         msg_conv = QueryChannelRange_clone(&msg_conv);
7195         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7196         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7197         return (uint64_t)ret_conv;
7198 }
7199
7200 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7201         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7202         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7203         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
7204         LDKPublicKey their_node_id_ref;
7205         CHECK(*((uint32_t*)their_node_id) == 33);
7206         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
7207         LDKQueryShortChannelIds msg_conv;
7208         msg_conv.inner = (void*)(msg & (~1));
7209         msg_conv.is_owned = (msg & 1) || (msg == 0);
7210         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7211         msg_conv = QueryShortChannelIds_clone(&msg_conv);
7212         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7213         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
7214         return (uint64_t)ret_conv;
7215 }
7216
7217 typedef struct LDKCustomMessageReader_JCalls {
7218         atomic_size_t refcnt;
7219         uint32_t read_meth;
7220 } LDKCustomMessageReader_JCalls;
7221 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
7222         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7223         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7224                 js_free(j_calls->read_meth);
7225                 FREE(j_calls);
7226         }
7227 }
7228 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
7229         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
7230         LDKu8slice buffer_var = buffer;
7231         int8_tArray buffer_arr = init_arr(buffer_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7232         memcpy((uint8_t*)(buffer_arr + 4), buffer_var.data, buffer_var.datalen);
7233         uint32_t ret = js_invoke_function_2(j_calls->read_meth, message_type, buffer_arr);
7234         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7235         CHECK_ACCESS(ret_ptr);
7236         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
7237         FREE((void*)ret);
7238         return ret_conv;
7239 }
7240 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
7241         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
7242         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7243 }
7244 static inline LDKCustomMessageReader LDKCustomMessageReader_init (/*TODO: JS Object Reference */void* o) {
7245         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
7246         atomic_init(&calls->refcnt, 1);
7247         //TODO: Assign calls->o from o
7248
7249         LDKCustomMessageReader ret = {
7250                 .this_arg = (void*) calls,
7251                 .read = read_LDKCustomMessageReader_jcall,
7252                 .free = LDKCustomMessageReader_JCalls_free,
7253         };
7254         return ret;
7255 }
7256 long  __attribute__((visibility("default"))) TS_LDKCustomMessageReader_new(/*TODO: JS Object Reference */void* o) {
7257         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
7258         *res_ptr = LDKCustomMessageReader_init(o);
7259         return (long)res_ptr;
7260 }
7261 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
7262         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7264         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
7265         LDKu8slice buffer_ref;
7266         buffer_ref.datalen = *((uint32_t*)buffer);
7267         buffer_ref.data = (int8_t*)(buffer + 4);
7268         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
7269         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
7270         return (uint64_t)ret_conv;
7271 }
7272
7273 typedef struct LDKCustomMessageHandler_JCalls {
7274         atomic_size_t refcnt;
7275         LDKCustomMessageReader_JCalls* CustomMessageReader;
7276         uint32_t handle_custom_message_meth;
7277         uint32_t get_and_clear_pending_msg_meth;
7278 } LDKCustomMessageHandler_JCalls;
7279 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
7280         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7281         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7282                 js_free(j_calls->handle_custom_message_meth);
7283                 js_free(j_calls->get_and_clear_pending_msg_meth);
7284                 FREE(j_calls);
7285         }
7286 }
7287 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
7288         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7289         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
7290         *msg_ret = msg;
7291         int8_tArray sender_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7292         memcpy((uint8_t*)(sender_node_id_arr + 4), sender_node_id.compressed_form, 33);
7293         uint32_t ret = js_invoke_function_2(j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
7294         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7295         CHECK_ACCESS(ret_ptr);
7296         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
7297         FREE((void*)ret);
7298         return ret_conv;
7299 }
7300 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
7301         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
7302         uint32_tArray ret = js_invoke_function_0(j_calls->get_and_clear_pending_msg_meth);
7303         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
7304         ret_constr.datalen = *((uint32_t*)ret);
7305         if (ret_constr.datalen > 0)
7306                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
7307         else
7308                 ret_constr.data = NULL;
7309         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7310         for (size_t z = 0; z < ret_constr.datalen; z++) {
7311                 uint32_t ret_conv_25 = ret_vals[z];
7312                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
7313                 CHECK_ACCESS(ret_conv_25_ptr);
7314                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
7315                 FREE((void*)ret_conv_25);
7316                 ret_constr.data[z] = ret_conv_25_conv;
7317         }
7318         return ret_constr;
7319 }
7320 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
7321         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
7322         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7323         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
7324 }
7325 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* CustomMessageReader) {
7326         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
7327         atomic_init(&calls->refcnt, 1);
7328         //TODO: Assign calls->o from o
7329
7330         LDKCustomMessageHandler ret = {
7331                 .this_arg = (void*) calls,
7332                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
7333                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
7334                 .free = LDKCustomMessageHandler_JCalls_free,
7335                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
7336         };
7337         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
7338         return ret;
7339 }
7340 long  __attribute__((visibility("default"))) TS_LDKCustomMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* CustomMessageReader) {
7341         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
7342         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
7343         return (long)res_ptr;
7344 }
7345 uint32_t  __attribute__((visibility("default"))) TS_CustomMessageHandler_handle_custom_message(uint32_t this_arg, uint32_t msg, int8_tArray sender_node_id) {
7346         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7347         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7348         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
7349         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
7350         CHECK_ACCESS(msg_ptr);
7351         LDKType msg_conv = *(LDKType*)(msg_ptr);
7352         LDKPublicKey sender_node_id_ref;
7353         CHECK(*((uint32_t*)sender_node_id) == 33);
7354         memcpy(sender_node_id_ref.compressed_form, (uint8_t*)(sender_node_id + 4), 33);
7355         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
7356         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
7357         return (uint64_t)ret_conv;
7358 }
7359
7360 uint32_tArray  __attribute__((visibility("default"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
7361         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7362         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7363         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
7364         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
7365         uint32_tArray ret_arr = NULL;
7366         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7367         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7368         for (size_t z = 0; z < ret_var.datalen; z++) {
7369                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
7370                 *ret_conv_25_conv = ret_var.data[z];
7371                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
7372         }
7373         
7374         FREE(ret_var.data);
7375         return ret_arr;
7376 }
7377
7378 typedef struct LDKSocketDescriptor_JCalls {
7379         atomic_size_t refcnt;
7380         uint32_t send_data_meth;
7381         uint32_t disconnect_socket_meth;
7382         uint32_t eq_meth;
7383         uint32_t hash_meth;
7384 } LDKSocketDescriptor_JCalls;
7385 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
7386         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7387         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7388                 js_free(j_calls->send_data_meth);
7389                 js_free(j_calls->disconnect_socket_meth);
7390                 js_free(j_calls->eq_meth);
7391                 js_free(j_calls->hash_meth);
7392                 FREE(j_calls);
7393         }
7394 }
7395 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
7396         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7397         LDKu8slice data_var = data;
7398         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7399         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
7400         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
7401 }
7402 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
7403         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7404         js_invoke_function_0(j_calls->disconnect_socket_meth);
7405 }
7406 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
7407         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7408         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7409         *other_arg_clone = SocketDescriptor_clone(other_arg);
7410         return js_invoke_function_1(j_calls->eq_meth, (uint64_t)other_arg_clone);
7411 }
7412 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
7413         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
7414         return js_invoke_function_0(j_calls->hash_meth);
7415 }
7416 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
7417         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
7418         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7419 }
7420 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
7421         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
7422         atomic_init(&calls->refcnt, 1);
7423         //TODO: Assign calls->o from o
7424
7425         LDKSocketDescriptor ret = {
7426                 .this_arg = (void*) calls,
7427                 .send_data = send_data_LDKSocketDescriptor_jcall,
7428                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
7429                 .eq = eq_LDKSocketDescriptor_jcall,
7430                 .hash = hash_LDKSocketDescriptor_jcall,
7431                 .cloned = LDKSocketDescriptor_JCalls_cloned,
7432                 .free = LDKSocketDescriptor_JCalls_free,
7433         };
7434         return ret;
7435 }
7436 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
7437         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
7438         *res_ptr = LDKSocketDescriptor_init(o);
7439         return (long)res_ptr;
7440 }
7441 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
7442         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7443         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7444         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7445         LDKu8slice data_ref;
7446         data_ref.datalen = *((uint32_t*)data);
7447         data_ref.data = (int8_t*)(data + 4);
7448         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
7449         return ret_val;
7450 }
7451
7452 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
7453         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7455         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7456         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
7457 }
7458
7459 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
7460         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7461         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7462         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
7463         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
7464         return ret_val;
7465 }
7466
7467 typedef struct LDKScore_JCalls {
7468         atomic_size_t refcnt;
7469         uint32_t channel_penalty_msat_meth;
7470         uint32_t payment_path_failed_meth;
7471         uint32_t payment_path_successful_meth;
7472         uint32_t write_meth;
7473 } LDKScore_JCalls;
7474 static void LDKScore_JCalls_free(void* this_arg) {
7475         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7476         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7477                 js_free(j_calls->channel_penalty_msat_meth);
7478                 js_free(j_calls->payment_path_failed_meth);
7479                 js_free(j_calls->payment_path_successful_meth);
7480                 js_free(j_calls->write_meth);
7481                 FREE(j_calls);
7482         }
7483 }
7484 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, LDKCOption_u64Z channel_capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
7485         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7486         LDKCOption_u64Z *channel_capacity_msat_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
7487         *channel_capacity_msat_copy = channel_capacity_msat;
7488         uint64_t channel_capacity_msat_ref = (uint64_t)channel_capacity_msat_copy;
7489         LDKNodeId source_var = *source;
7490         uint64_t source_ref = 0;
7491         source_var = NodeId_clone(source);
7492         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7493         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7494         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
7495         source_ref = (uint64_t)source_var.inner;
7496         if (source_var.is_owned) {
7497                 source_ref |= 1;
7498         }
7499         LDKNodeId target_var = *target;
7500         uint64_t target_ref = 0;
7501         target_var = NodeId_clone(target);
7502         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7503         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7504         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
7505         target_ref = (uint64_t)target_var.inner;
7506         if (target_var.is_owned) {
7507                 target_ref |= 1;
7508         }
7509         return js_invoke_function_5(j_calls->channel_penalty_msat_meth, short_channel_id, send_amt_msat, channel_capacity_msat_ref, source_ref, target_ref);
7510 }
7511 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
7512         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7513         LDKCVec_RouteHopZ path_var = path;
7514         uint32_tArray path_arr = NULL;
7515         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7516         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
7517         for (size_t k = 0; k < path_var.datalen; k++) {
7518                 LDKRouteHop path_conv_10_var = path_var.data[k];
7519                 uint64_t path_conv_10_ref = 0;
7520                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7521                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7522                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
7523                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
7524                 if (path_conv_10_var.is_owned) {
7525                         path_conv_10_ref |= 1;
7526                 }
7527                 path_arr_ptr[k] = path_conv_10_ref;
7528         }
7529         
7530         FREE(path_var.data);
7531         js_invoke_function_2(j_calls->payment_path_failed_meth, path_arr, short_channel_id);
7532 }
7533 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
7534         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7535         LDKCVec_RouteHopZ path_var = path;
7536         uint32_tArray path_arr = NULL;
7537         path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7538         uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
7539         for (size_t k = 0; k < path_var.datalen; k++) {
7540                 LDKRouteHop path_conv_10_var = path_var.data[k];
7541                 uint64_t path_conv_10_ref = 0;
7542                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7543                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7544                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
7545                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
7546                 if (path_conv_10_var.is_owned) {
7547                         path_conv_10_ref |= 1;
7548                 }
7549                 path_arr_ptr[k] = path_conv_10_ref;
7550         }
7551         
7552         FREE(path_var.data);
7553         js_invoke_function_1(j_calls->payment_path_successful_meth, path_arr);
7554 }
7555 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
7556         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
7557         int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
7558         LDKCVec_u8Z ret_ref;
7559         ret_ref.datalen = *((uint32_t*)ret);
7560         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7561         memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
7562         return ret_ref;
7563 }
7564 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
7565         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
7566         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7567 }
7568 static inline LDKScore LDKScore_init (/*TODO: JS Object Reference */void* o) {
7569         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
7570         atomic_init(&calls->refcnt, 1);
7571         //TODO: Assign calls->o from o
7572
7573         LDKScore ret = {
7574                 .this_arg = (void*) calls,
7575                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
7576                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
7577                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
7578                 .write = write_LDKScore_jcall,
7579                 .free = LDKScore_JCalls_free,
7580         };
7581         return ret;
7582 }
7583 long  __attribute__((visibility("default"))) TS_LDKScore_new(/*TODO: JS Object Reference */void* o) {
7584         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
7585         *res_ptr = LDKScore_init(o);
7586         return (long)res_ptr;
7587 }
7588 int64_t  __attribute__((visibility("default"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, uint32_t channel_capacity_msat, uint32_t source, uint32_t target) {
7589         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7591         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7592         void* channel_capacity_msat_ptr = (void*)(((uint64_t)channel_capacity_msat) & ~1);
7593         CHECK_ACCESS(channel_capacity_msat_ptr);
7594         LDKCOption_u64Z channel_capacity_msat_conv = *(LDKCOption_u64Z*)(channel_capacity_msat_ptr);
7595         channel_capacity_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)channel_capacity_msat) & ~1));
7596         LDKNodeId source_conv;
7597         source_conv.inner = (void*)(source & (~1));
7598         source_conv.is_owned = false;
7599         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
7600         LDKNodeId target_conv;
7601         target_conv.inner = (void*)(target & (~1));
7602         target_conv.is_owned = false;
7603         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
7604         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, channel_capacity_msat_conv, &source_conv, &target_conv);
7605         return ret_val;
7606 }
7607
7608 void  __attribute__((visibility("default"))) TS_Score_payment_path_failed(uint32_t this_arg, uint32_tArray path, int64_t short_channel_id) {
7609         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7610         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7611         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7612         LDKCVec_RouteHopZ path_constr;
7613         path_constr.datalen = *((uint32_t*)path);
7614         if (path_constr.datalen > 0)
7615                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7616         else
7617                 path_constr.data = NULL;
7618         uint32_t* path_vals = (uint32_t*)(path + 4);
7619         for (size_t k = 0; k < path_constr.datalen; k++) {
7620                 uint32_t path_conv_10 = path_vals[k];
7621                 LDKRouteHop path_conv_10_conv;
7622                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
7623                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
7624                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
7625                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
7626                 path_constr.data[k] = path_conv_10_conv;
7627         }
7628         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
7629 }
7630
7631 void  __attribute__((visibility("default"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
7632         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7633         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7634         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7635         LDKCVec_RouteHopZ path_constr;
7636         path_constr.datalen = *((uint32_t*)path);
7637         if (path_constr.datalen > 0)
7638                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
7639         else
7640                 path_constr.data = NULL;
7641         uint32_t* path_vals = (uint32_t*)(path + 4);
7642         for (size_t k = 0; k < path_constr.datalen; k++) {
7643                 uint32_t path_conv_10 = path_vals[k];
7644                 LDKRouteHop path_conv_10_conv;
7645                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
7646                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
7647                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
7648                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
7649                 path_constr.data[k] = path_conv_10_conv;
7650         }
7651         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
7652 }
7653
7654 int8_tArray  __attribute__((visibility("default"))) TS_Score_write(uint32_t this_arg) {
7655         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7656         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7657         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
7658         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7659         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7660         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
7661         CVec_u8Z_free(ret_var);
7662         return ret_arr;
7663 }
7664
7665 typedef struct LDKLockableScore_JCalls {
7666         atomic_size_t refcnt;
7667         uint32_t lock_meth;
7668 } LDKLockableScore_JCalls;
7669 static void LDKLockableScore_JCalls_free(void* this_arg) {
7670         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
7671         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7672                 js_free(j_calls->lock_meth);
7673                 FREE(j_calls);
7674         }
7675 }
7676 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
7677         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
7678         uint32_t ret = js_invoke_function_0(j_calls->lock_meth);
7679         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7680         CHECK_ACCESS(ret_ptr);
7681         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// Warning: we may need a move here but no clone is available for LDKScore
7682         
7683         return ret_conv;
7684 }
7685 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
7686         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
7687         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7688 }
7689 static inline LDKLockableScore LDKLockableScore_init (/*TODO: JS Object Reference */void* o) {
7690         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
7691         atomic_init(&calls->refcnt, 1);
7692         //TODO: Assign calls->o from o
7693
7694         LDKLockableScore ret = {
7695                 .this_arg = (void*) calls,
7696                 .lock = lock_LDKLockableScore_jcall,
7697                 .free = LDKLockableScore_JCalls_free,
7698         };
7699         return ret;
7700 }
7701 long  __attribute__((visibility("default"))) TS_LDKLockableScore_new(/*TODO: JS Object Reference */void* o) {
7702         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
7703         *res_ptr = LDKLockableScore_init(o);
7704         return (long)res_ptr;
7705 }
7706 uint32_t  __attribute__((visibility("default"))) TS_LockableScore_lock(uint32_t this_arg) {
7707         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7708         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7709         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
7710         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
7711         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
7712         return (uint64_t)ret_ret;
7713 }
7714
7715 typedef struct LDKChannelManagerPersister_JCalls {
7716         atomic_size_t refcnt;
7717         uint32_t persist_manager_meth;
7718 } LDKChannelManagerPersister_JCalls;
7719 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
7720         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7721         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7722                 js_free(j_calls->persist_manager_meth);
7723                 FREE(j_calls);
7724         }
7725 }
7726 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
7727         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
7728         LDKChannelManager channel_manager_var = *channel_manager;
7729         uint64_t channel_manager_ref = 0;
7730         // Warning: we may need a move here but no clone is available for LDKChannelManager
7731         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7732         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7733         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
7734         channel_manager_ref = (uint64_t)channel_manager_var.inner;
7735         if (channel_manager_var.is_owned) {
7736                 channel_manager_ref |= 1;
7737         }
7738         uint32_t ret = js_invoke_function_1(j_calls->persist_manager_meth, channel_manager_ref);
7739         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7740         CHECK_ACCESS(ret_ptr);
7741         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
7742         FREE((void*)ret);
7743         return ret_conv;
7744 }
7745 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
7746         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
7747         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7748 }
7749 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (/*TODO: JS Object Reference */void* o) {
7750         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
7751         atomic_init(&calls->refcnt, 1);
7752         //TODO: Assign calls->o from o
7753
7754         LDKChannelManagerPersister ret = {
7755                 .this_arg = (void*) calls,
7756                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
7757                 .free = LDKChannelManagerPersister_JCalls_free,
7758         };
7759         return ret;
7760 }
7761 long  __attribute__((visibility("default"))) TS_LDKChannelManagerPersister_new(/*TODO: JS Object Reference */void* o) {
7762         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
7763         *res_ptr = LDKChannelManagerPersister_init(o);
7764         return (long)res_ptr;
7765 }
7766 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerPersister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
7767         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7768         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7769         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
7770         LDKChannelManager channel_manager_conv;
7771         channel_manager_conv.inner = (void*)(channel_manager & (~1));
7772         channel_manager_conv.is_owned = false;
7773         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
7774         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
7775         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
7776         return (uint64_t)ret_conv;
7777 }
7778
7779 uint32_t __attribute__((visibility("default"))) TS_LDKFallback_ref_from_ptr(uint32_t ptr) {
7780         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
7781         switch(obj->tag) {
7782                 case LDKFallback_SegWitProgram: {
7783                         uint8_t version_val = obj->seg_wit_program.version._0;
7784                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
7785                         int8_tArray program_arr = init_arr(program_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7786                         memcpy((uint8_t*)(program_arr + 4), program_var.data, program_var.datalen);
7787                         return 0 /* LDKFallback - SegWitProgram */; (void) version_val; (void) program_arr;
7788                 }
7789                 case LDKFallback_PubKeyHash: {
7790                         int8_tArray pub_key_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7791                         memcpy((uint8_t*)(pub_key_hash_arr + 4), obj->pub_key_hash.data, 20);
7792                         return 0 /* LDKFallback - PubKeyHash */; (void) pub_key_hash_arr;
7793                 }
7794                 case LDKFallback_ScriptHash: {
7795                         int8_tArray script_hash_arr = init_arr(20, sizeof(uint8_t), "Native int8_tArray Bytes");
7796                         memcpy((uint8_t*)(script_hash_arr + 4), obj->script_hash.data, 20);
7797                         return 0 /* LDKFallback - ScriptHash */; (void) script_hash_arr;
7798                 }
7799                 default: abort();
7800         }
7801 }
7802 typedef struct LDKPayer_JCalls {
7803         atomic_size_t refcnt;
7804         uint32_t node_id_meth;
7805         uint32_t first_hops_meth;
7806         uint32_t send_payment_meth;
7807         uint32_t send_spontaneous_payment_meth;
7808         uint32_t retry_payment_meth;
7809         uint32_t abandon_payment_meth;
7810 } LDKPayer_JCalls;
7811 static void LDKPayer_JCalls_free(void* this_arg) {
7812         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7813         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7814                 js_free(j_calls->node_id_meth);
7815                 js_free(j_calls->first_hops_meth);
7816                 js_free(j_calls->send_payment_meth);
7817                 js_free(j_calls->send_spontaneous_payment_meth);
7818                 js_free(j_calls->retry_payment_meth);
7819                 js_free(j_calls->abandon_payment_meth);
7820                 FREE(j_calls);
7821         }
7822 }
7823 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
7824         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7825         int8_tArray ret = js_invoke_function_0(j_calls->node_id_meth);
7826         LDKPublicKey ret_ref;
7827         CHECK(*((uint32_t*)ret) == 33);
7828         memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
7829         return ret_ref;
7830 }
7831 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
7832         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7833         uint32_tArray ret = js_invoke_function_0(j_calls->first_hops_meth);
7834         LDKCVec_ChannelDetailsZ ret_constr;
7835         ret_constr.datalen = *((uint32_t*)ret);
7836         if (ret_constr.datalen > 0)
7837                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
7838         else
7839                 ret_constr.data = NULL;
7840         uint32_t* ret_vals = (uint32_t*)(ret + 4);
7841         for (size_t q = 0; q < ret_constr.datalen; q++) {
7842                 uint32_t ret_conv_16 = ret_vals[q];
7843                 LDKChannelDetails ret_conv_16_conv;
7844                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
7845                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
7846                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
7847                 ret_constr.data[q] = ret_conv_16_conv;
7848         }
7849         return ret_constr;
7850 }
7851 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
7852         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7853         LDKRoute route_var = *route;
7854         uint64_t route_ref = 0;
7855         route_var = Route_clone(route);
7856         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7857         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7858         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
7859         route_ref = (uint64_t)route_var.inner;
7860         if (route_var.is_owned) {
7861                 route_ref |= 1;
7862         }
7863         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7864         memcpy((uint8_t*)(payment_hash_arr + 4), payment_hash.data, 32);
7865         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7866         memcpy((uint8_t*)(payment_secret_arr + 4), payment_secret.data, 32);
7867         uint32_t ret = js_invoke_function_3(j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
7868         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7869         CHECK_ACCESS(ret_ptr);
7870         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
7871         FREE((void*)ret);
7872         return ret_conv;
7873 }
7874 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
7875         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7876         LDKRoute route_var = *route;
7877         uint64_t route_ref = 0;
7878         route_var = Route_clone(route);
7879         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7880         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7881         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
7882         route_ref = (uint64_t)route_var.inner;
7883         if (route_var.is_owned) {
7884                 route_ref |= 1;
7885         }
7886         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7887         memcpy((uint8_t*)(payment_preimage_arr + 4), payment_preimage.data, 32);
7888         uint32_t ret = js_invoke_function_2(j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
7889         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7890         CHECK_ACCESS(ret_ptr);
7891         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
7892         FREE((void*)ret);
7893         return ret_conv;
7894 }
7895 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
7896         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7897         LDKRoute route_var = *route;
7898         uint64_t route_ref = 0;
7899         route_var = Route_clone(route);
7900         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7901         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7902         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
7903         route_ref = (uint64_t)route_var.inner;
7904         if (route_var.is_owned) {
7905                 route_ref |= 1;
7906         }
7907         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7908         memcpy((uint8_t*)(payment_id_arr + 4), payment_id.data, 32);
7909         uint32_t ret = js_invoke_function_2(j_calls->retry_payment_meth, route_ref, payment_id_arr);
7910         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7911         CHECK_ACCESS(ret_ptr);
7912         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
7913         FREE((void*)ret);
7914         return ret_conv;
7915 }
7916 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
7917         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
7918         int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7919         memcpy((uint8_t*)(payment_id_arr + 4), payment_id.data, 32);
7920         js_invoke_function_1(j_calls->abandon_payment_meth, payment_id_arr);
7921 }
7922 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
7923         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
7924         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7925 }
7926 static inline LDKPayer LDKPayer_init (/*TODO: JS Object Reference */void* o) {
7927         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
7928         atomic_init(&calls->refcnt, 1);
7929         //TODO: Assign calls->o from o
7930
7931         LDKPayer ret = {
7932                 .this_arg = (void*) calls,
7933                 .node_id = node_id_LDKPayer_jcall,
7934                 .first_hops = first_hops_LDKPayer_jcall,
7935                 .send_payment = send_payment_LDKPayer_jcall,
7936                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
7937                 .retry_payment = retry_payment_LDKPayer_jcall,
7938                 .abandon_payment = abandon_payment_LDKPayer_jcall,
7939                 .free = LDKPayer_JCalls_free,
7940         };
7941         return ret;
7942 }
7943 long  __attribute__((visibility("default"))) TS_LDKPayer_new(/*TODO: JS Object Reference */void* o) {
7944         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
7945         *res_ptr = LDKPayer_init(o);
7946         return (long)res_ptr;
7947 }
7948 int8_tArray  __attribute__((visibility("default"))) TS_Payer_node_id(uint32_t this_arg) {
7949         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7950         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7951         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7952         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7953         memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
7954         return ret_arr;
7955 }
7956
7957 uint32_tArray  __attribute__((visibility("default"))) TS_Payer_first_hops(uint32_t this_arg) {
7958         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7959         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7960         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7961         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
7962         uint32_tArray ret_arr = NULL;
7963         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7964         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7965         for (size_t q = 0; q < ret_var.datalen; q++) {
7966                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
7967                 uint64_t ret_conv_16_ref = 0;
7968                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7969                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7970                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
7971                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
7972                 if (ret_conv_16_var.is_owned) {
7973                         ret_conv_16_ref |= 1;
7974                 }
7975                 ret_arr_ptr[q] = ret_conv_16_ref;
7976         }
7977         
7978         FREE(ret_var.data);
7979         return ret_arr;
7980 }
7981
7982 uint32_t  __attribute__((visibility("default"))) TS_Payer_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
7983         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7984         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7985         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
7986         LDKRoute route_conv;
7987         route_conv.inner = (void*)(route & (~1));
7988         route_conv.is_owned = false;
7989         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
7990         LDKThirtyTwoBytes payment_hash_ref;
7991         CHECK(*((uint32_t*)payment_hash) == 32);
7992         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
7993         LDKThirtyTwoBytes payment_secret_ref;
7994         CHECK(*((uint32_t*)payment_secret) == 32);
7995         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
7996         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
7997         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
7998         return (uint64_t)ret_conv;
7999 }
8000
8001 uint32_t  __attribute__((visibility("default"))) TS_Payer_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
8002         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8003         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8004         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8005         LDKRoute route_conv;
8006         route_conv.inner = (void*)(route & (~1));
8007         route_conv.is_owned = false;
8008         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
8009         LDKThirtyTwoBytes payment_preimage_ref;
8010         CHECK(*((uint32_t*)payment_preimage) == 32);
8011         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
8012         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
8013         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
8014         return (uint64_t)ret_conv;
8015 }
8016
8017 uint32_t  __attribute__((visibility("default"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
8018         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8019         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8020         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8021         LDKRoute route_conv;
8022         route_conv.inner = (void*)(route & (~1));
8023         route_conv.is_owned = false;
8024         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
8025         LDKThirtyTwoBytes payment_id_ref;
8026         CHECK(*((uint32_t*)payment_id) == 32);
8027         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
8028         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8029         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
8030         return (uint64_t)ret_conv;
8031 }
8032
8033 void  __attribute__((visibility("default"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
8034         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8035         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8036         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
8037         LDKThirtyTwoBytes payment_id_ref;
8038         CHECK(*((uint32_t*)payment_id) == 32);
8039         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
8040         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
8041 }
8042
8043 typedef struct LDKRouter_JCalls {
8044         atomic_size_t refcnt;
8045         uint32_t find_route_meth;
8046 } LDKRouter_JCalls;
8047 static void LDKRouter_JCalls_free(void* this_arg) {
8048         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8049         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8050                 js_free(j_calls->find_route_meth);
8051                 FREE(j_calls);
8052         }
8053 }
8054 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, const uint8_t (* payment_hash)[32], LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
8055         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
8056         int8_tArray payer_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8057         memcpy((uint8_t*)(payer_arr + 4), payer.compressed_form, 33);
8058         LDKRouteParameters params_var = *params;
8059         uint64_t params_ref = 0;
8060         params_var = RouteParameters_clone(params);
8061         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8062         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8063         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_var);
8064         params_ref = (uint64_t)params_var.inner;
8065         if (params_var.is_owned) {
8066                 params_ref |= 1;
8067         }
8068         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8069         memcpy((uint8_t*)(payment_hash_arr + 4), *payment_hash, 32);
8070         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
8071         uint32_tArray first_hops_arr = NULL;
8072         if (first_hops != NULL) {
8073                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
8074                 first_hops_arr = init_arr(first_hops_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
8075                 uint32_t *first_hops_arr_ptr = (uint32_t*)(first_hops_arr + 4);
8076                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
8077                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
8078                         uint64_t first_hops_conv_16_ref = 0;
8079                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8080                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8081                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
8082                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
8083                         if (first_hops_conv_16_var.is_owned) {
8084                                 first_hops_conv_16_ref |= 1;
8085                         }
8086                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
8087                 }
8088         
8089         }
8090         // WARNING: This object doesn't live past this scope, needs clone!
8091         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
8092         uint32_t ret = js_invoke_function_5(j_calls->find_route_meth, payer_arr, params_ref, payment_hash_arr, first_hops_arr, ret_scorer);
8093         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8094         CHECK_ACCESS(ret_ptr);
8095         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
8096         FREE((void*)ret);
8097         return ret_conv;
8098 }
8099 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
8100         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
8101         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8102 }
8103 static inline LDKRouter LDKRouter_init (/*TODO: JS Object Reference */void* o) {
8104         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
8105         atomic_init(&calls->refcnt, 1);
8106         //TODO: Assign calls->o from o
8107
8108         LDKRouter ret = {
8109                 .this_arg = (void*) calls,
8110                 .find_route = find_route_LDKRouter_jcall,
8111                 .free = LDKRouter_JCalls_free,
8112         };
8113         return ret;
8114 }
8115 long  __attribute__((visibility("default"))) TS_LDKRouter_new(/*TODO: JS Object Reference */void* o) {
8116         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
8117         *res_ptr = LDKRouter_init(o);
8118         return (long)res_ptr;
8119 }
8120 uint32_t  __attribute__((visibility("default"))) TS_Router_find_route(uint32_t this_arg, int8_tArray payer, uint32_t params, int8_tArray payment_hash, uint32_tArray first_hops, uint32_t scorer) {
8121         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8122         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8123         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
8124         LDKPublicKey payer_ref;
8125         CHECK(*((uint32_t*)payer) == 33);
8126         memcpy(payer_ref.compressed_form, (uint8_t*)(payer + 4), 33);
8127         LDKRouteParameters params_conv;
8128         params_conv.inner = (void*)(params & (~1));
8129         params_conv.is_owned = false;
8130         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
8131         unsigned char payment_hash_arr[32];
8132         CHECK(*((uint32_t*)payment_hash) == 32);
8133         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
8134         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
8135         LDKCVec_ChannelDetailsZ first_hops_constr;
8136         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
8137         if (first_hops != 0) {
8138                 first_hops_constr.datalen = *((uint32_t*)first_hops);
8139                 if (first_hops_constr.datalen > 0)
8140                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
8141                 else
8142                         first_hops_constr.data = NULL;
8143                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
8144                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
8145                         uint32_t first_hops_conv_16 = first_hops_vals[q];
8146                         LDKChannelDetails first_hops_conv_16_conv;
8147                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
8148                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
8149                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
8150                         first_hops_constr.data[q] = first_hops_conv_16_conv;
8151                 }
8152                 first_hops_ptr = &first_hops_constr;
8153         }
8154         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
8155         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
8156         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
8157         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
8158         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, payment_hash_ref, first_hops_ptr, scorer_conv);
8159         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
8160         return (uint64_t)ret_conv;
8161 }
8162
8163 jstring  __attribute__((visibility("default"))) TS__ldk_get_compiled_version() {
8164         LDKStr ret_str = _ldk_get_compiled_version();
8165         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8166         Str_free(ret_str);
8167         return ret_conv;
8168 }
8169
8170 jstring  __attribute__((visibility("default"))) TS__ldk_c_bindings_get_compiled_version() {
8171         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8172         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8173         Str_free(ret_str);
8174         return ret_conv;
8175 }
8176
8177 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
8178         LDKTransaction _res_ref;
8179         _res_ref.datalen = *((uint32_t*)_res);
8180         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8181         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
8182         _res_ref.data_is_owned = true;
8183         Transaction_free(_res_ref);
8184 }
8185
8186 uint32_t  __attribute__((visibility("default"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
8187         LDKCVec_u8Z script_pubkey_ref;
8188         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
8189         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8190         memcpy(script_pubkey_ref.data, (uint8_t*)(script_pubkey + 4), script_pubkey_ref.datalen);
8191         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8192         *ret_ref = TxOut_new(script_pubkey_ref, value);
8193         return (uint64_t)ret_ref;
8194 }
8195
8196 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
8197         if ((_res & 1) != 0) return;
8198         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8199         CHECK_ACCESS(_res_ptr);
8200         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
8201         FREE((void*)_res);
8202         TxOut_free(_res_conv);
8203 }
8204
8205 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
8206         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8207         *ret_ref = TxOut_clone(arg);
8208         return (uint64_t)ret_ref;
8209 }
8210 int64_t  __attribute__((visibility("default"))) TS_TxOut_clone_ptr(uint32_t arg) {
8211         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
8212         int64_t ret_val = TxOut_clone_ptr(arg_conv);
8213         return ret_val;
8214 }
8215
8216 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
8217         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8218         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8219         *ret_ref = TxOut_clone(orig_conv);
8220         return (uint64_t)ret_ref;
8221 }
8222
8223 void  __attribute__((visibility("default"))) TS_Str_free(jstring _res) {
8224         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8225         Str_free(dummy);
8226 }
8227
8228 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
8229         LDKSecretKey o_ref;
8230         CHECK(*((uint32_t*)o) == 32);
8231         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
8232         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8233         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
8234         return (uint64_t)ret_conv;
8235 }
8236
8237 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
8238         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8239         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
8240         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
8241         return (uint64_t)ret_conv;
8242 }
8243
8244 jboolean  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
8245         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
8246         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
8247         return ret_val;
8248 }
8249
8250 void  __attribute__((visibility("default"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
8251         if ((_res & 1) != 0) return;
8252         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8253         CHECK_ACCESS(_res_ptr);
8254         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
8255         FREE((void*)_res);
8256         CResult_SecretKeyErrorZ_free(_res_conv);
8257 }
8258
8259 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
8260         LDKPublicKey o_ref;
8261         CHECK(*((uint32_t*)o) == 33);
8262         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
8263         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8264         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
8265         return (uint64_t)ret_conv;
8266 }
8267
8268 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
8269         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8270         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8271         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
8272         return (uint64_t)ret_conv;
8273 }
8274
8275 jboolean  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
8276         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
8277         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
8278         return ret_val;
8279 }
8280
8281 void  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
8282         if ((_res & 1) != 0) return;
8283         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8284         CHECK_ACCESS(_res_ptr);
8285         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
8286         FREE((void*)_res);
8287         CResult_PublicKeyErrorZ_free(_res_conv);
8288 }
8289
8290 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
8291         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8292         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
8293         return (uint64_t)ret_conv;
8294 }
8295 int64_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
8296         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
8297         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
8298         return ret_val;
8299 }
8300
8301 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
8302         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
8303         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
8304         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
8305         return (uint64_t)ret_conv;
8306 }
8307
8308 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
8309         LDKTxCreationKeys o_conv;
8310         o_conv.inner = (void*)(o & (~1));
8311         o_conv.is_owned = (o & 1) || (o == 0);
8312         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8313         o_conv = TxCreationKeys_clone(&o_conv);
8314         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8315         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
8316         return (uint64_t)ret_conv;
8317 }
8318
8319 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
8320         LDKDecodeError e_conv;
8321         e_conv.inner = (void*)(e & (~1));
8322         e_conv.is_owned = (e & 1) || (e == 0);
8323         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8324         e_conv = DecodeError_clone(&e_conv);
8325         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8326         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
8327         return (uint64_t)ret_conv;
8328 }
8329
8330 jboolean  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
8331         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
8332         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
8333         return ret_val;
8334 }
8335
8336 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
8337         if ((_res & 1) != 0) return;
8338         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8339         CHECK_ACCESS(_res_ptr);
8340         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
8341         FREE((void*)_res);
8342         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
8343 }
8344
8345 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
8346         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8347         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
8348         return (uint64_t)ret_conv;
8349 }
8350 int64_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
8351         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
8352         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
8353         return ret_val;
8354 }
8355
8356 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
8357         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
8358         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
8359         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
8360         return (uint64_t)ret_conv;
8361 }
8362
8363 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
8364         LDKChannelPublicKeys o_conv;
8365         o_conv.inner = (void*)(o & (~1));
8366         o_conv.is_owned = (o & 1) || (o == 0);
8367         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8368         o_conv = ChannelPublicKeys_clone(&o_conv);
8369         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8370         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
8371         return (uint64_t)ret_conv;
8372 }
8373
8374 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
8375         LDKDecodeError e_conv;
8376         e_conv.inner = (void*)(e & (~1));
8377         e_conv.is_owned = (e & 1) || (e == 0);
8378         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8379         e_conv = DecodeError_clone(&e_conv);
8380         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8381         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
8382         return (uint64_t)ret_conv;
8383 }
8384
8385 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
8386         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
8387         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
8388         return ret_val;
8389 }
8390
8391 void  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
8392         if ((_res & 1) != 0) return;
8393         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8394         CHECK_ACCESS(_res_ptr);
8395         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
8396         FREE((void*)_res);
8397         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
8398 }
8399
8400 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
8401         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8402         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
8403         return (uint64_t)ret_conv;
8404 }
8405 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
8406         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
8407         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
8408         return ret_val;
8409 }
8410
8411 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
8412         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
8413         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
8414         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
8415         return (uint64_t)ret_conv;
8416 }
8417
8418 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
8419         LDKTxCreationKeys o_conv;
8420         o_conv.inner = (void*)(o & (~1));
8421         o_conv.is_owned = (o & 1) || (o == 0);
8422         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8423         o_conv = TxCreationKeys_clone(&o_conv);
8424         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8425         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
8426         return (uint64_t)ret_conv;
8427 }
8428
8429 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
8430         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
8431         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8432         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
8433         return (uint64_t)ret_conv;
8434 }
8435
8436 jboolean  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
8437         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
8438         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
8439         return ret_val;
8440 }
8441
8442 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
8443         if ((_res & 1) != 0) return;
8444         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8445         CHECK_ACCESS(_res_ptr);
8446         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
8447         FREE((void*)_res);
8448         CResult_TxCreationKeysErrorZ_free(_res_conv);
8449 }
8450
8451 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
8452         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8453         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
8454         return (uint64_t)ret_conv;
8455 }
8456 int64_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
8457         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
8458         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
8459         return ret_val;
8460 }
8461
8462 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
8463         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
8464         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
8465         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
8466         return (uint64_t)ret_conv;
8467 }
8468
8469 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_some(int32_t o) {
8470         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8471         *ret_copy = COption_u32Z_some(o);
8472         uint64_t ret_ref = (uint64_t)ret_copy;
8473         return ret_ref;
8474 }
8475
8476 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_none() {
8477         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8478         *ret_copy = COption_u32Z_none();
8479         uint64_t ret_ref = (uint64_t)ret_copy;
8480         return ret_ref;
8481 }
8482
8483 void  __attribute__((visibility("default"))) TS_COption_u32Z_free(uint32_t _res) {
8484         if ((_res & 1) != 0) return;
8485         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8486         CHECK_ACCESS(_res_ptr);
8487         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
8488         FREE((void*)_res);
8489         COption_u32Z_free(_res_conv);
8490 }
8491
8492 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
8493         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8494         *ret_copy = COption_u32Z_clone(arg);
8495 uint64_t ret_ref = (uint64_t)ret_copy;
8496         return ret_ref;
8497 }
8498 int64_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
8499         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
8500         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
8501         return ret_val;
8502 }
8503
8504 uint32_t  __attribute__((visibility("default"))) TS_COption_u32Z_clone(uint32_t orig) {
8505         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
8506         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
8507         *ret_copy = COption_u32Z_clone(orig_conv);
8508         uint64_t ret_ref = (uint64_t)ret_copy;
8509         return ret_ref;
8510 }
8511
8512 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
8513         LDKHTLCOutputInCommitment o_conv;
8514         o_conv.inner = (void*)(o & (~1));
8515         o_conv.is_owned = (o & 1) || (o == 0);
8516         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8517         o_conv = HTLCOutputInCommitment_clone(&o_conv);
8518         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8519         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
8520         return (uint64_t)ret_conv;
8521 }
8522
8523 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
8524         LDKDecodeError e_conv;
8525         e_conv.inner = (void*)(e & (~1));
8526         e_conv.is_owned = (e & 1) || (e == 0);
8527         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8528         e_conv = DecodeError_clone(&e_conv);
8529         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8530         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
8531         return (uint64_t)ret_conv;
8532 }
8533
8534 jboolean  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
8535         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
8536         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
8537         return ret_val;
8538 }
8539
8540 void  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
8541         if ((_res & 1) != 0) return;
8542         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8543         CHECK_ACCESS(_res_ptr);
8544         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
8545         FREE((void*)_res);
8546         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
8547 }
8548
8549 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
8550         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8551         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
8552         return (uint64_t)ret_conv;
8553 }
8554 int64_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
8555         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
8556         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
8557         return ret_val;
8558 }
8559
8560 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
8561         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
8562         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
8563         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
8564         return (uint64_t)ret_conv;
8565 }
8566
8567 uint32_t  __attribute__((visibility("default"))) TS_COption_NoneZ_some() {
8568         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
8569         return ret_conv;
8570 }
8571
8572 uint32_t  __attribute__((visibility("default"))) TS_COption_NoneZ_none() {
8573         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
8574         return ret_conv;
8575 }
8576
8577 void  __attribute__((visibility("default"))) TS_COption_NoneZ_free(uint32_t _res) {
8578         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
8579         COption_NoneZ_free(_res_conv);
8580 }
8581
8582 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
8583         LDKCounterpartyChannelTransactionParameters o_conv;
8584         o_conv.inner = (void*)(o & (~1));
8585         o_conv.is_owned = (o & 1) || (o == 0);
8586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8587         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
8588         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8589         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8590         return (uint64_t)ret_conv;
8591 }
8592
8593 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
8594         LDKDecodeError e_conv;
8595         e_conv.inner = (void*)(e & (~1));
8596         e_conv.is_owned = (e & 1) || (e == 0);
8597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8598         e_conv = DecodeError_clone(&e_conv);
8599         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8600         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
8601         return (uint64_t)ret_conv;
8602 }
8603
8604 jboolean  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
8605         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
8606         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
8607         return ret_val;
8608 }
8609
8610 void  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
8611         if ((_res & 1) != 0) return;
8612         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8613         CHECK_ACCESS(_res_ptr);
8614         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
8615         FREE((void*)_res);
8616         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8617 }
8618
8619 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
8620         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8621         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
8622         return (uint64_t)ret_conv;
8623 }
8624 int64_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
8625         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
8626         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
8627         return ret_val;
8628 }
8629
8630 uint32_t  __attribute__((visibility("default"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
8631         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8632         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
8633         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8634         return (uint64_t)ret_conv;
8635 }
8636
8637 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
8638         LDKChannelTransactionParameters o_conv;
8639         o_conv.inner = (void*)(o & (~1));
8640         o_conv.is_owned = (o & 1) || (o == 0);
8641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8642         o_conv = ChannelTransactionParameters_clone(&o_conv);
8643         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8644         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
8645         return (uint64_t)ret_conv;
8646 }
8647
8648 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
8649         LDKDecodeError e_conv;
8650         e_conv.inner = (void*)(e & (~1));
8651         e_conv.is_owned = (e & 1) || (e == 0);
8652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8653         e_conv = DecodeError_clone(&e_conv);
8654         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8655         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
8656         return (uint64_t)ret_conv;
8657 }
8658
8659 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
8660         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
8661         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
8662         return ret_val;
8663 }
8664
8665 void  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
8666         if ((_res & 1) != 0) return;
8667         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8668         CHECK_ACCESS(_res_ptr);
8669         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
8670         FREE((void*)_res);
8671         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
8672 }
8673
8674 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
8675         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8676         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
8677         return (uint64_t)ret_conv;
8678 }
8679 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
8680         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
8681         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
8682         return ret_val;
8683 }
8684
8685 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
8686         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
8687         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
8688         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
8689         return (uint64_t)ret_conv;
8690 }
8691
8692 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
8693         LDKCVec_SignatureZ _res_constr;
8694         _res_constr.datalen = *((uint32_t*)_res);
8695         if (_res_constr.datalen > 0)
8696                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8697         else
8698                 _res_constr.data = NULL;
8699         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
8700         for (size_t m = 0; m < _res_constr.datalen; m++) {
8701                 int8_tArray _res_conv_12 = _res_vals[m];
8702                 LDKSignature _res_conv_12_ref;
8703                 CHECK(*((uint32_t*)_res_conv_12) == 64);
8704                 memcpy(_res_conv_12_ref.compact_form, (uint8_t*)(_res_conv_12 + 4), 64);
8705                 _res_constr.data[m] = _res_conv_12_ref;
8706         }
8707         CVec_SignatureZ_free(_res_constr);
8708 }
8709
8710 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8711         LDKHolderCommitmentTransaction o_conv;
8712         o_conv.inner = (void*)(o & (~1));
8713         o_conv.is_owned = (o & 1) || (o == 0);
8714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8715         o_conv = HolderCommitmentTransaction_clone(&o_conv);
8716         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8717         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
8718         return (uint64_t)ret_conv;
8719 }
8720
8721 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8722         LDKDecodeError e_conv;
8723         e_conv.inner = (void*)(e & (~1));
8724         e_conv.is_owned = (e & 1) || (e == 0);
8725         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8726         e_conv = DecodeError_clone(&e_conv);
8727         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8728         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
8729         return (uint64_t)ret_conv;
8730 }
8731
8732 jboolean  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
8733         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
8734         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
8735         return ret_val;
8736 }
8737
8738 void  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8739         if ((_res & 1) != 0) return;
8740         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8741         CHECK_ACCESS(_res_ptr);
8742         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
8743         FREE((void*)_res);
8744         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
8745 }
8746
8747 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
8748         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8749         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
8750         return (uint64_t)ret_conv;
8751 }
8752 int64_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
8753         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
8754         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
8755         return ret_val;
8756 }
8757
8758 uint32_t  __attribute__((visibility("default"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8759         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8760         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
8761         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8762         return (uint64_t)ret_conv;
8763 }
8764
8765 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8766         LDKBuiltCommitmentTransaction o_conv;
8767         o_conv.inner = (void*)(o & (~1));
8768         o_conv.is_owned = (o & 1) || (o == 0);
8769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8770         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
8771         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8772         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
8773         return (uint64_t)ret_conv;
8774 }
8775
8776 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8777         LDKDecodeError e_conv;
8778         e_conv.inner = (void*)(e & (~1));
8779         e_conv.is_owned = (e & 1) || (e == 0);
8780         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8781         e_conv = DecodeError_clone(&e_conv);
8782         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8783         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
8784         return (uint64_t)ret_conv;
8785 }
8786
8787 jboolean  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
8788         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
8789         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
8790         return ret_val;
8791 }
8792
8793 void  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8794         if ((_res & 1) != 0) return;
8795         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8796         CHECK_ACCESS(_res_ptr);
8797         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
8798         FREE((void*)_res);
8799         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
8800 }
8801
8802 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
8803         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8804         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
8805         return (uint64_t)ret_conv;
8806 }
8807 int64_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
8808         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
8809         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
8810         return ret_val;
8811 }
8812
8813 uint32_t  __attribute__((visibility("default"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8814         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
8815         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
8816         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
8817         return (uint64_t)ret_conv;
8818 }
8819
8820 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
8821         LDKTrustedClosingTransaction o_conv;
8822         o_conv.inner = (void*)(o & (~1));
8823         o_conv.is_owned = (o & 1) || (o == 0);
8824         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8825         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
8826         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
8827         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
8828         return (uint64_t)ret_conv;
8829 }
8830
8831 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
8832         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
8833         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
8834         return (uint64_t)ret_conv;
8835 }
8836
8837 jboolean  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
8838         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
8839         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
8840         return ret_val;
8841 }
8842
8843 void  __attribute__((visibility("default"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
8844         if ((_res & 1) != 0) return;
8845         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8846         CHECK_ACCESS(_res_ptr);
8847         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
8848         FREE((void*)_res);
8849         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
8850 }
8851
8852 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
8853         LDKCommitmentTransaction o_conv;
8854         o_conv.inner = (void*)(o & (~1));
8855         o_conv.is_owned = (o & 1) || (o == 0);
8856         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8857         o_conv = CommitmentTransaction_clone(&o_conv);
8858         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8859         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
8860         return (uint64_t)ret_conv;
8861 }
8862
8863 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
8864         LDKDecodeError e_conv;
8865         e_conv.inner = (void*)(e & (~1));
8866         e_conv.is_owned = (e & 1) || (e == 0);
8867         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
8868         e_conv = DecodeError_clone(&e_conv);
8869         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8870         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
8871         return (uint64_t)ret_conv;
8872 }
8873
8874 jboolean  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
8875         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
8876         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
8877         return ret_val;
8878 }
8879
8880 void  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
8881         if ((_res & 1) != 0) return;
8882         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8883         CHECK_ACCESS(_res_ptr);
8884         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
8885         FREE((void*)_res);
8886         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
8887 }
8888
8889 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
8890         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8891         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
8892         return (uint64_t)ret_conv;
8893 }
8894 int64_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
8895         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
8896         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
8897         return ret_val;
8898 }
8899
8900 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
8901         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
8902         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
8903         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
8904         return (uint64_t)ret_conv;
8905 }
8906
8907 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
8908         LDKTrustedCommitmentTransaction o_conv;
8909         o_conv.inner = (void*)(o & (~1));
8910         o_conv.is_owned = (o & 1) || (o == 0);
8911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8912         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
8913         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
8914         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
8915         return (uint64_t)ret_conv;
8916 }
8917
8918 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
8919         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
8920         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
8921         return (uint64_t)ret_conv;
8922 }
8923
8924 jboolean  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
8925         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
8926         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
8927         return ret_val;
8928 }
8929
8930 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
8931         if ((_res & 1) != 0) return;
8932         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8933         CHECK_ACCESS(_res_ptr);
8934         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
8935         FREE((void*)_res);
8936         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
8937 }
8938
8939 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
8940         LDKCVec_SignatureZ o_constr;
8941         o_constr.datalen = *((uint32_t*)o);
8942         if (o_constr.datalen > 0)
8943                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8944         else
8945                 o_constr.data = NULL;
8946         int8_tArray* o_vals = (int8_tArray*)(o + 4);
8947         for (size_t m = 0; m < o_constr.datalen; m++) {
8948                 int8_tArray o_conv_12 = o_vals[m];
8949                 LDKSignature o_conv_12_ref;
8950                 CHECK(*((uint32_t*)o_conv_12) == 64);
8951                 memcpy(o_conv_12_ref.compact_form, (uint8_t*)(o_conv_12 + 4), 64);
8952                 o_constr.data[m] = o_conv_12_ref;
8953         }
8954         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8955         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
8956         return (uint64_t)ret_conv;
8957 }
8958
8959 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
8960         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8961         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
8962         return (uint64_t)ret_conv;
8963 }
8964
8965 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
8966         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
8967         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
8968         return ret_val;
8969 }
8970
8971 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
8972         if ((_res & 1) != 0) return;
8973         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
8974         CHECK_ACCESS(_res_ptr);
8975         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
8976         FREE((void*)_res);
8977         CResult_CVec_SignatureZNoneZ_free(_res_conv);
8978 }
8979
8980 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
8981         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8982         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
8983         return (uint64_t)ret_conv;
8984 }
8985 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
8986         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
8987         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
8988         return ret_val;
8989 }
8990
8991 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
8992         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
8993         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
8994         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
8995         return (uint64_t)ret_conv;
8996 }
8997
8998 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
8999         LDKShutdownScript o_conv;
9000         o_conv.inner = (void*)(o & (~1));
9001         o_conv.is_owned = (o & 1) || (o == 0);
9002         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9003         o_conv = ShutdownScript_clone(&o_conv);
9004         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9005         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
9006         return (uint64_t)ret_conv;
9007 }
9008
9009 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
9010         LDKDecodeError e_conv;
9011         e_conv.inner = (void*)(e & (~1));
9012         e_conv.is_owned = (e & 1) || (e == 0);
9013         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9014         e_conv = DecodeError_clone(&e_conv);
9015         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9016         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
9017         return (uint64_t)ret_conv;
9018 }
9019
9020 jboolean  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
9021         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
9022         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
9023         return ret_val;
9024 }
9025
9026 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
9027         if ((_res & 1) != 0) return;
9028         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9029         CHECK_ACCESS(_res_ptr);
9030         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
9031         FREE((void*)_res);
9032         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
9033 }
9034
9035 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
9036         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9037         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
9038         return (uint64_t)ret_conv;
9039 }
9040 int64_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
9041         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
9042         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
9043         return ret_val;
9044 }
9045
9046 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
9047         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
9048         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9049         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
9050         return (uint64_t)ret_conv;
9051 }
9052
9053 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
9054         LDKShutdownScript o_conv;
9055         o_conv.inner = (void*)(o & (~1));
9056         o_conv.is_owned = (o & 1) || (o == 0);
9057         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9058         o_conv = ShutdownScript_clone(&o_conv);
9059         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9060         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
9061         return (uint64_t)ret_conv;
9062 }
9063
9064 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
9065         LDKInvalidShutdownScript e_conv;
9066         e_conv.inner = (void*)(e & (~1));
9067         e_conv.is_owned = (e & 1) || (e == 0);
9068         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9069         e_conv = InvalidShutdownScript_clone(&e_conv);
9070         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9071         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
9072         return (uint64_t)ret_conv;
9073 }
9074
9075 jboolean  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
9076         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
9077         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
9078         return ret_val;
9079 }
9080
9081 void  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
9082         if ((_res & 1) != 0) return;
9083         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9084         CHECK_ACCESS(_res_ptr);
9085         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
9086         FREE((void*)_res);
9087         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
9088 }
9089
9090 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
9091         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9092         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
9093         return (uint64_t)ret_conv;
9094 }
9095 int64_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
9096         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
9097         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
9098         return ret_val;
9099 }
9100
9101 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
9102         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
9103         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9104         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
9105         return (uint64_t)ret_conv;
9106 }
9107
9108 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_ok() {
9109         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9110         *ret_conv = CResult_NoneErrorZ_ok();
9111         return (uint64_t)ret_conv;
9112 }
9113
9114 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
9115         LDKIOError e_conv = LDKIOError_from_js(e);
9116         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9117         *ret_conv = CResult_NoneErrorZ_err(e_conv);
9118         return (uint64_t)ret_conv;
9119 }
9120
9121 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
9122         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
9123         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
9124         return ret_val;
9125 }
9126
9127 void  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
9128         if ((_res & 1) != 0) return;
9129         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9130         CHECK_ACCESS(_res_ptr);
9131         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
9132         FREE((void*)_res);
9133         CResult_NoneErrorZ_free(_res_conv);
9134 }
9135
9136 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
9137         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9138         *ret_conv = CResult_NoneErrorZ_clone(arg);
9139         return (uint64_t)ret_conv;
9140 }
9141 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
9142         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
9143         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
9144         return ret_val;
9145 }
9146
9147 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
9148         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
9149         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
9150         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
9151         return (uint64_t)ret_conv;
9152 }
9153
9154 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
9155         LDKRouteHop o_conv;
9156         o_conv.inner = (void*)(o & (~1));
9157         o_conv.is_owned = (o & 1) || (o == 0);
9158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9159         o_conv = RouteHop_clone(&o_conv);
9160         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9161         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
9162         return (uint64_t)ret_conv;
9163 }
9164
9165 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
9166         LDKDecodeError e_conv;
9167         e_conv.inner = (void*)(e & (~1));
9168         e_conv.is_owned = (e & 1) || (e == 0);
9169         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9170         e_conv = DecodeError_clone(&e_conv);
9171         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9172         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
9173         return (uint64_t)ret_conv;
9174 }
9175
9176 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
9177         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
9178         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
9179         return ret_val;
9180 }
9181
9182 void  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
9183         if ((_res & 1) != 0) return;
9184         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9185         CHECK_ACCESS(_res_ptr);
9186         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
9187         FREE((void*)_res);
9188         CResult_RouteHopDecodeErrorZ_free(_res_conv);
9189 }
9190
9191 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
9192         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9193         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
9194         return (uint64_t)ret_conv;
9195 }
9196 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
9197         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
9198         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
9199         return ret_val;
9200 }
9201
9202 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
9203         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
9204         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
9205         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
9206         return (uint64_t)ret_conv;
9207 }
9208
9209 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
9210         LDKCVec_RouteHopZ _res_constr;
9211         _res_constr.datalen = *((uint32_t*)_res);
9212         if (_res_constr.datalen > 0)
9213                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9214         else
9215                 _res_constr.data = NULL;
9216         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9217         for (size_t k = 0; k < _res_constr.datalen; k++) {
9218                 uint32_t _res_conv_10 = _res_vals[k];
9219                 LDKRouteHop _res_conv_10_conv;
9220                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
9221                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
9222                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
9223                 _res_constr.data[k] = _res_conv_10_conv;
9224         }
9225         CVec_RouteHopZ_free(_res_constr);
9226 }
9227
9228 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
9229         LDKCVec_CVec_RouteHopZZ _res_constr;
9230         _res_constr.datalen = *((uint32_t*)_res);
9231         if (_res_constr.datalen > 0)
9232                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
9233         else
9234                 _res_constr.data = NULL;
9235         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
9236         for (size_t m = 0; m < _res_constr.datalen; m++) {
9237                 uint32_tArray _res_conv_12 = _res_vals[m];
9238                 LDKCVec_RouteHopZ _res_conv_12_constr;
9239                 _res_conv_12_constr.datalen = *((uint32_t*)_res_conv_12);
9240                 if (_res_conv_12_constr.datalen > 0)
9241                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
9242                 else
9243                         _res_conv_12_constr.data = NULL;
9244                 uint32_t* _res_conv_12_vals = (uint32_t*)(_res_conv_12 + 4);
9245                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
9246                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
9247                         LDKRouteHop _res_conv_12_conv_10_conv;
9248                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
9249                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
9250                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
9251                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
9252                 }
9253                 _res_constr.data[m] = _res_conv_12_constr;
9254         }
9255         CVec_CVec_RouteHopZZ_free(_res_constr);
9256 }
9257
9258 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
9259         LDKRoute o_conv;
9260         o_conv.inner = (void*)(o & (~1));
9261         o_conv.is_owned = (o & 1) || (o == 0);
9262         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9263         o_conv = Route_clone(&o_conv);
9264         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9265         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
9266         return (uint64_t)ret_conv;
9267 }
9268
9269 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
9270         LDKDecodeError e_conv;
9271         e_conv.inner = (void*)(e & (~1));
9272         e_conv.is_owned = (e & 1) || (e == 0);
9273         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9274         e_conv = DecodeError_clone(&e_conv);
9275         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9276         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
9277         return (uint64_t)ret_conv;
9278 }
9279
9280 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
9281         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
9282         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
9283         return ret_val;
9284 }
9285
9286 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
9287         if ((_res & 1) != 0) return;
9288         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9289         CHECK_ACCESS(_res_ptr);
9290         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
9291         FREE((void*)_res);
9292         CResult_RouteDecodeErrorZ_free(_res_conv);
9293 }
9294
9295 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
9296         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9297         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
9298         return (uint64_t)ret_conv;
9299 }
9300 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
9301         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
9302         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
9303         return ret_val;
9304 }
9305
9306 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
9307         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
9308         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
9309         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
9310         return (uint64_t)ret_conv;
9311 }
9312
9313 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
9314         LDKRouteParameters o_conv;
9315         o_conv.inner = (void*)(o & (~1));
9316         o_conv.is_owned = (o & 1) || (o == 0);
9317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9318         o_conv = RouteParameters_clone(&o_conv);
9319         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9320         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
9321         return (uint64_t)ret_conv;
9322 }
9323
9324 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
9325         LDKDecodeError e_conv;
9326         e_conv.inner = (void*)(e & (~1));
9327         e_conv.is_owned = (e & 1) || (e == 0);
9328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9329         e_conv = DecodeError_clone(&e_conv);
9330         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9331         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
9332         return (uint64_t)ret_conv;
9333 }
9334
9335 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
9336         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
9337         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
9338         return ret_val;
9339 }
9340
9341 void  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
9342         if ((_res & 1) != 0) return;
9343         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9344         CHECK_ACCESS(_res_ptr);
9345         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
9346         FREE((void*)_res);
9347         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
9348 }
9349
9350 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
9351         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9352         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
9353         return (uint64_t)ret_conv;
9354 }
9355 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9356         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
9357         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
9358         return ret_val;
9359 }
9360
9361 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
9362         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
9363         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
9364         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
9365         return (uint64_t)ret_conv;
9366 }
9367
9368 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
9369         LDKCVec_RouteHintZ _res_constr;
9370         _res_constr.datalen = *((uint32_t*)_res);
9371         if (_res_constr.datalen > 0)
9372                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
9373         else
9374                 _res_constr.data = NULL;
9375         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9376         for (size_t l = 0; l < _res_constr.datalen; l++) {
9377                 uint32_t _res_conv_11 = _res_vals[l];
9378                 LDKRouteHint _res_conv_11_conv;
9379                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
9380                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
9381                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
9382                 _res_constr.data[l] = _res_conv_11_conv;
9383         }
9384         CVec_RouteHintZ_free(_res_constr);
9385 }
9386
9387 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_some(int64_t o) {
9388         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9389         *ret_copy = COption_u64Z_some(o);
9390         uint64_t ret_ref = (uint64_t)ret_copy;
9391         return ret_ref;
9392 }
9393
9394 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_none() {
9395         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9396         *ret_copy = COption_u64Z_none();
9397         uint64_t ret_ref = (uint64_t)ret_copy;
9398         return ret_ref;
9399 }
9400
9401 void  __attribute__((visibility("default"))) TS_COption_u64Z_free(uint32_t _res) {
9402         if ((_res & 1) != 0) return;
9403         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9404         CHECK_ACCESS(_res_ptr);
9405         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
9406         FREE((void*)_res);
9407         COption_u64Z_free(_res_conv);
9408 }
9409
9410 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
9411         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9412         *ret_copy = COption_u64Z_clone(arg);
9413 uint64_t ret_ref = (uint64_t)ret_copy;
9414         return ret_ref;
9415 }
9416 int64_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
9417         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
9418         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
9419         return ret_val;
9420 }
9421
9422 uint32_t  __attribute__((visibility("default"))) TS_COption_u64Z_clone(uint32_t orig) {
9423         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
9424         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
9425         *ret_copy = COption_u64Z_clone(orig_conv);
9426         uint64_t ret_ref = (uint64_t)ret_copy;
9427         return ret_ref;
9428 }
9429
9430 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
9431         LDKPayee o_conv;
9432         o_conv.inner = (void*)(o & (~1));
9433         o_conv.is_owned = (o & 1) || (o == 0);
9434         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9435         o_conv = Payee_clone(&o_conv);
9436         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9437         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
9438         return (uint64_t)ret_conv;
9439 }
9440
9441 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_err(uint32_t e) {
9442         LDKDecodeError e_conv;
9443         e_conv.inner = (void*)(e & (~1));
9444         e_conv.is_owned = (e & 1) || (e == 0);
9445         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9446         e_conv = DecodeError_clone(&e_conv);
9447         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9448         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
9449         return (uint64_t)ret_conv;
9450 }
9451
9452 jboolean  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_is_ok(uint32_t o) {
9453         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
9454         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
9455         return ret_val;
9456 }
9457
9458 void  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
9459         if ((_res & 1) != 0) return;
9460         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9461         CHECK_ACCESS(_res_ptr);
9462         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
9463         FREE((void*)_res);
9464         CResult_PayeeDecodeErrorZ_free(_res_conv);
9465 }
9466
9467 static inline uint64_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
9468         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9469         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
9470         return (uint64_t)ret_conv;
9471 }
9472 int64_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone_ptr(uint32_t arg) {
9473         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
9474         int64_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
9475         return ret_val;
9476 }
9477
9478 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
9479         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
9480         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
9481         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
9482         return (uint64_t)ret_conv;
9483 }
9484
9485 void  __attribute__((visibility("default"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
9486         LDKCVec_RouteHintHopZ _res_constr;
9487         _res_constr.datalen = *((uint32_t*)_res);
9488         if (_res_constr.datalen > 0)
9489                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
9490         else
9491                 _res_constr.data = NULL;
9492         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9493         for (size_t o = 0; o < _res_constr.datalen; o++) {
9494                 uint32_t _res_conv_14 = _res_vals[o];
9495                 LDKRouteHintHop _res_conv_14_conv;
9496                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
9497                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
9498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
9499                 _res_constr.data[o] = _res_conv_14_conv;
9500         }
9501         CVec_RouteHintHopZ_free(_res_constr);
9502 }
9503
9504 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
9505         LDKRouteHint o_conv;
9506         o_conv.inner = (void*)(o & (~1));
9507         o_conv.is_owned = (o & 1) || (o == 0);
9508         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9509         o_conv = RouteHint_clone(&o_conv);
9510         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9511         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
9512         return (uint64_t)ret_conv;
9513 }
9514
9515 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
9516         LDKDecodeError e_conv;
9517         e_conv.inner = (void*)(e & (~1));
9518         e_conv.is_owned = (e & 1) || (e == 0);
9519         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9520         e_conv = DecodeError_clone(&e_conv);
9521         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9522         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
9523         return (uint64_t)ret_conv;
9524 }
9525
9526 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
9527         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
9528         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
9529         return ret_val;
9530 }
9531
9532 void  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
9533         if ((_res & 1) != 0) return;
9534         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9535         CHECK_ACCESS(_res_ptr);
9536         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
9537         FREE((void*)_res);
9538         CResult_RouteHintDecodeErrorZ_free(_res_conv);
9539 }
9540
9541 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
9542         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9543         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
9544         return (uint64_t)ret_conv;
9545 }
9546 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
9547         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
9548         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
9549         return ret_val;
9550 }
9551
9552 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
9553         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
9554         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
9555         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
9556         return (uint64_t)ret_conv;
9557 }
9558
9559 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
9560         LDKRouteHintHop o_conv;
9561         o_conv.inner = (void*)(o & (~1));
9562         o_conv.is_owned = (o & 1) || (o == 0);
9563         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9564         o_conv = RouteHintHop_clone(&o_conv);
9565         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9566         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
9567         return (uint64_t)ret_conv;
9568 }
9569
9570 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
9571         LDKDecodeError e_conv;
9572         e_conv.inner = (void*)(e & (~1));
9573         e_conv.is_owned = (e & 1) || (e == 0);
9574         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9575         e_conv = DecodeError_clone(&e_conv);
9576         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9577         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
9578         return (uint64_t)ret_conv;
9579 }
9580
9581 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
9582         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
9583         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
9584         return ret_val;
9585 }
9586
9587 void  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
9588         if ((_res & 1) != 0) return;
9589         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9590         CHECK_ACCESS(_res_ptr);
9591         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
9592         FREE((void*)_res);
9593         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
9594 }
9595
9596 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
9597         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9598         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
9599         return (uint64_t)ret_conv;
9600 }
9601 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
9602         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
9603         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
9604         return ret_val;
9605 }
9606
9607 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
9608         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
9609         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
9610         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
9611         return (uint64_t)ret_conv;
9612 }
9613
9614 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
9615         LDKCVec_ChannelDetailsZ _res_constr;
9616         _res_constr.datalen = *((uint32_t*)_res);
9617         if (_res_constr.datalen > 0)
9618                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
9619         else
9620                 _res_constr.data = NULL;
9621         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9622         for (size_t q = 0; q < _res_constr.datalen; q++) {
9623                 uint32_t _res_conv_16 = _res_vals[q];
9624                 LDKChannelDetails _res_conv_16_conv;
9625                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
9626                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
9627                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
9628                 _res_constr.data[q] = _res_conv_16_conv;
9629         }
9630         CVec_ChannelDetailsZ_free(_res_constr);
9631 }
9632
9633 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
9634         LDKRoute o_conv;
9635         o_conv.inner = (void*)(o & (~1));
9636         o_conv.is_owned = (o & 1) || (o == 0);
9637         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9638         o_conv = Route_clone(&o_conv);
9639         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9640         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
9641         return (uint64_t)ret_conv;
9642 }
9643
9644 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
9645         LDKLightningError e_conv;
9646         e_conv.inner = (void*)(e & (~1));
9647         e_conv.is_owned = (e & 1) || (e == 0);
9648         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9649         e_conv = LightningError_clone(&e_conv);
9650         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9651         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
9652         return (uint64_t)ret_conv;
9653 }
9654
9655 jboolean  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
9656         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
9657         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
9658         return ret_val;
9659 }
9660
9661 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
9662         if ((_res & 1) != 0) return;
9663         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9664         CHECK_ACCESS(_res_ptr);
9665         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
9666         FREE((void*)_res);
9667         CResult_RouteLightningErrorZ_free(_res_conv);
9668 }
9669
9670 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
9671         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9672         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
9673         return (uint64_t)ret_conv;
9674 }
9675 int64_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
9676         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
9677         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
9678         return ret_val;
9679 }
9680
9681 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
9682         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
9683         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
9684         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
9685         return (uint64_t)ret_conv;
9686 }
9687
9688 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
9689         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9690         CHECK_ACCESS(o_ptr);
9691         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
9692         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
9693         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9694         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
9695         return (uint64_t)ret_conv;
9696 }
9697
9698 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
9699         LDKAccessError e_conv = LDKAccessError_from_js(e);
9700         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9701         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
9702         return (uint64_t)ret_conv;
9703 }
9704
9705 jboolean  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
9706         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
9707         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
9708         return ret_val;
9709 }
9710
9711 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
9712         if ((_res & 1) != 0) return;
9713         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9714         CHECK_ACCESS(_res_ptr);
9715         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
9716         FREE((void*)_res);
9717         CResult_TxOutAccessErrorZ_free(_res_conv);
9718 }
9719
9720 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
9721         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9722         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
9723         return (uint64_t)ret_conv;
9724 }
9725 int64_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
9726         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
9727         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
9728         return ret_val;
9729 }
9730
9731 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
9732         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
9733         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
9734         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
9735         return (uint64_t)ret_conv;
9736 }
9737
9738 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
9739         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9740         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
9741         return ((uint64_t)ret_conv);
9742 }
9743 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
9744         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
9745         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
9746         return ret_val;
9747 }
9748
9749 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
9750         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
9751         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9752         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
9753         return ((uint64_t)ret_conv);
9754 }
9755
9756 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
9757         LDKTransaction b_ref;
9758         b_ref.datalen = *((uint32_t*)b);
9759         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
9760         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
9761         b_ref.data_is_owned = true;
9762         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
9763         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
9764         return ((uint64_t)ret_conv);
9765 }
9766
9767 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
9768         if ((_res & 1) != 0) return;
9769         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9770         CHECK_ACCESS(_res_ptr);
9771         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
9772         FREE((void*)_res);
9773         C2Tuple_usizeTransactionZ_free(_res_conv);
9774 }
9775
9776 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
9777         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
9778         _res_constr.datalen = *((uint32_t*)_res);
9779         if (_res_constr.datalen > 0)
9780                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
9781         else
9782                 _res_constr.data = NULL;
9783         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9784         for (size_t c = 0; c < _res_constr.datalen; c++) {
9785                 uint32_t _res_conv_28 = _res_vals[c];
9786                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
9787                 CHECK_ACCESS(_res_conv_28_ptr);
9788                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
9789                 FREE((void*)_res_conv_28);
9790                 _res_constr.data[c] = _res_conv_28_conv;
9791         }
9792         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
9793 }
9794
9795 void  __attribute__((visibility("default"))) TS_CVec_TxidZ_free(ptrArray _res) {
9796         LDKCVec_TxidZ _res_constr;
9797         _res_constr.datalen = *((uint32_t*)_res);
9798         if (_res_constr.datalen > 0)
9799                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
9800         else
9801                 _res_constr.data = NULL;
9802         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
9803         for (size_t m = 0; m < _res_constr.datalen; m++) {
9804                 int8_tArray _res_conv_12 = _res_vals[m];
9805                 LDKThirtyTwoBytes _res_conv_12_ref;
9806                 CHECK(*((uint32_t*)_res_conv_12) == 32);
9807                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), 32);
9808                 _res_constr.data[m] = _res_conv_12_ref;
9809         }
9810         CVec_TxidZ_free(_res_constr);
9811 }
9812
9813 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
9814         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9815         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
9816         return (uint64_t)ret_conv;
9817 }
9818
9819 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
9820         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
9821         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9822         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
9823         return (uint64_t)ret_conv;
9824 }
9825
9826 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
9827         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
9828         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
9829         return ret_val;
9830 }
9831
9832 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
9833         if ((_res & 1) != 0) return;
9834         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9835         CHECK_ACCESS(_res_ptr);
9836         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
9837         FREE((void*)_res);
9838         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
9839 }
9840
9841 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
9842         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9843         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
9844         return (uint64_t)ret_conv;
9845 }
9846 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
9847         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
9848         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
9849         return ret_val;
9850 }
9851
9852 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
9853         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
9854         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9855         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
9856         return (uint64_t)ret_conv;
9857 }
9858
9859 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
9860         LDKCVec_MonitorEventZ _res_constr;
9861         _res_constr.datalen = *((uint32_t*)_res);
9862         if (_res_constr.datalen > 0)
9863                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
9864         else
9865                 _res_constr.data = NULL;
9866         uint32_t* _res_vals = (uint32_t*)(_res + 4);
9867         for (size_t o = 0; o < _res_constr.datalen; o++) {
9868                 uint32_t _res_conv_14 = _res_vals[o];
9869                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
9870                 CHECK_ACCESS(_res_conv_14_ptr);
9871                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
9872                 FREE((void*)_res_conv_14);
9873                 _res_constr.data[o] = _res_conv_14_conv;
9874         }
9875         CVec_MonitorEventZ_free(_res_constr);
9876 }
9877
9878 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
9879         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9880         CHECK_ACCESS(o_ptr);
9881         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
9882         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
9883         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9884         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
9885         uint64_t ret_ref = (uint64_t)ret_copy;
9886         return ret_ref;
9887 }
9888
9889 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
9890         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9891         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
9892         uint64_t ret_ref = (uint64_t)ret_copy;
9893         return ret_ref;
9894 }
9895
9896 void  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
9897         if ((_res & 1) != 0) return;
9898         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9899         CHECK_ACCESS(_res_ptr);
9900         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
9901         FREE((void*)_res);
9902         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
9903 }
9904
9905 static inline uint64_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
9906         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9907         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
9908 uint64_t ret_ref = (uint64_t)ret_copy;
9909         return ret_ref;
9910 }
9911 int64_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
9912         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
9913         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
9914         return ret_val;
9915 }
9916
9917 uint32_t  __attribute__((visibility("default"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
9918         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
9919         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
9920         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
9921         uint64_t ret_ref = (uint64_t)ret_copy;
9922         return ret_ref;
9923 }
9924
9925 uint32_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
9926         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9927         CHECK_ACCESS(o_ptr);
9928         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
9929         o_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)o) & ~1));
9930         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9931         *ret_copy = COption_ClosureReasonZ_some(o_conv);
9932         uint64_t ret_ref = (uint64_t)ret_copy;
9933         return ret_ref;
9934 }
9935
9936 uint32_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_none() {
9937         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9938         *ret_copy = COption_ClosureReasonZ_none();
9939         uint64_t ret_ref = (uint64_t)ret_copy;
9940         return ret_ref;
9941 }
9942
9943 void  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
9944         if ((_res & 1) != 0) return;
9945         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
9946         CHECK_ACCESS(_res_ptr);
9947         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
9948         FREE((void*)_res);
9949         COption_ClosureReasonZ_free(_res_conv);
9950 }
9951
9952 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
9953         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9954         *ret_copy = COption_ClosureReasonZ_clone(arg);
9955 uint64_t ret_ref = (uint64_t)ret_copy;
9956         return ret_ref;
9957 }
9958 int64_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
9959         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
9960         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
9961         return ret_val;
9962 }
9963
9964 uint32_t  __attribute__((visibility("default"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
9965         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
9966         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
9967         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
9968         uint64_t ret_ref = (uint64_t)ret_copy;
9969         return ret_ref;
9970 }
9971
9972 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
9973         void* o_ptr = (void*)(((uint64_t)o) & ~1);
9974         CHECK_ACCESS(o_ptr);
9975         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
9976         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uint64_t)o) & ~1));
9977         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
9978         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
9979         return (uint64_t)ret_conv;
9980 }
9981
9982 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
9983         LDKDecodeError e_conv;
9984         e_conv.inner = (void*)(e & (~1));
9985         e_conv.is_owned = (e & 1) || (e == 0);
9986         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9987         e_conv = DecodeError_clone(&e_conv);
9988         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
9989         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
9990         return (uint64_t)ret_conv;
9991 }
9992
9993 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
9994         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
9995         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
9996         return ret_val;
9997 }
9998
9999 void  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
10000         if ((_res & 1) != 0) return;
10001         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10002         CHECK_ACCESS(_res_ptr);
10003         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
10004         FREE((void*)_res);
10005         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
10006 }
10007
10008 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
10009         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
10010         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
10011         return (uint64_t)ret_conv;
10012 }
10013 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
10014         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
10015         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
10016         return ret_val;
10017 }
10018
10019 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
10020         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
10021         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
10022         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
10023         return (uint64_t)ret_conv;
10024 }
10025
10026 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
10027         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10028         CHECK_ACCESS(o_ptr);
10029         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
10030         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
10031         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
10032         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
10033         uint64_t ret_ref = (uint64_t)ret_copy;
10034         return ret_ref;
10035 }
10036
10037 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_none() {
10038         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
10039         *ret_copy = COption_NetworkUpdateZ_none();
10040         uint64_t ret_ref = (uint64_t)ret_copy;
10041         return ret_ref;
10042 }
10043
10044 void  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
10045         if ((_res & 1) != 0) return;
10046         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10047         CHECK_ACCESS(_res_ptr);
10048         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
10049         FREE((void*)_res);
10050         COption_NetworkUpdateZ_free(_res_conv);
10051 }
10052
10053 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
10054         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
10055         *ret_copy = COption_NetworkUpdateZ_clone(arg);
10056 uint64_t ret_ref = (uint64_t)ret_copy;
10057         return ret_ref;
10058 }
10059 int64_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
10060         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
10061         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
10062         return ret_val;
10063 }
10064
10065 uint32_t  __attribute__((visibility("default"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
10066         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
10067         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
10068         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
10069         uint64_t ret_ref = (uint64_t)ret_copy;
10070         return ret_ref;
10071 }
10072
10073 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
10074         LDKCVec_SpendableOutputDescriptorZ _res_constr;
10075         _res_constr.datalen = *((uint32_t*)_res);
10076         if (_res_constr.datalen > 0)
10077                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
10078         else
10079                 _res_constr.data = NULL;
10080         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10081         for (size_t b = 0; b < _res_constr.datalen; b++) {
10082                 uint32_t _res_conv_27 = _res_vals[b];
10083                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
10084                 CHECK_ACCESS(_res_conv_27_ptr);
10085                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
10086                 FREE((void*)_res_conv_27);
10087                 _res_constr.data[b] = _res_conv_27_conv;
10088         }
10089         CVec_SpendableOutputDescriptorZ_free(_res_constr);
10090 }
10091
10092 uint32_t  __attribute__((visibility("default"))) TS_COption_EventZ_some(uint32_t o) {
10093         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10094         CHECK_ACCESS(o_ptr);
10095         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
10096         o_conv = Event_clone((LDKEvent*)(((uint64_t)o) & ~1));
10097         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
10098         *ret_copy = COption_EventZ_some(o_conv);
10099         uint64_t ret_ref = (uint64_t)ret_copy;
10100         return ret_ref;
10101 }
10102
10103 uint32_t  __attribute__((visibility("default"))) TS_COption_EventZ_none() {
10104         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
10105         *ret_copy = COption_EventZ_none();
10106         uint64_t ret_ref = (uint64_t)ret_copy;
10107         return ret_ref;
10108 }
10109
10110 void  __attribute__((visibility("default"))) TS_COption_EventZ_free(uint32_t _res) {
10111         if ((_res & 1) != 0) return;
10112         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10113         CHECK_ACCESS(_res_ptr);
10114         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
10115         FREE((void*)_res);
10116         COption_EventZ_free(_res_conv);
10117 }
10118
10119 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
10120         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
10121         *ret_copy = COption_EventZ_clone(arg);
10122 uint64_t ret_ref = (uint64_t)ret_copy;
10123         return ret_ref;
10124 }
10125 int64_t  __attribute__((visibility("default"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
10126         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
10127         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
10128         return ret_val;
10129 }
10130
10131 uint32_t  __attribute__((visibility("default"))) TS_COption_EventZ_clone(uint32_t orig) {
10132         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
10133         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
10134         *ret_copy = COption_EventZ_clone(orig_conv);
10135         uint64_t ret_ref = (uint64_t)ret_copy;
10136         return ret_ref;
10137 }
10138
10139 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
10140         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10141         CHECK_ACCESS(o_ptr);
10142         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
10143         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uint64_t)o) & ~1));
10144         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
10145         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
10146         return (uint64_t)ret_conv;
10147 }
10148
10149 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
10150         LDKDecodeError e_conv;
10151         e_conv.inner = (void*)(e & (~1));
10152         e_conv.is_owned = (e & 1) || (e == 0);
10153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10154         e_conv = DecodeError_clone(&e_conv);
10155         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
10156         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
10157         return (uint64_t)ret_conv;
10158 }
10159
10160 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
10161         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
10162         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
10163         return ret_val;
10164 }
10165
10166 void  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
10167         if ((_res & 1) != 0) return;
10168         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10169         CHECK_ACCESS(_res_ptr);
10170         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
10171         FREE((void*)_res);
10172         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
10173 }
10174
10175 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
10176         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
10177         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
10178         return (uint64_t)ret_conv;
10179 }
10180 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
10181         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
10182         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
10183         return ret_val;
10184 }
10185
10186 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
10187         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
10188         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
10189         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
10190         return (uint64_t)ret_conv;
10191 }
10192
10193 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
10194         LDKCVec_MessageSendEventZ _res_constr;
10195         _res_constr.datalen = *((uint32_t*)_res);
10196         if (_res_constr.datalen > 0)
10197                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10198         else
10199                 _res_constr.data = NULL;
10200         uint32_t* _res_vals = (uint32_t*)(_res + 4);
10201         for (size_t s = 0; s < _res_constr.datalen; s++) {
10202                 uint32_t _res_conv_18 = _res_vals[s];
10203                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
10204                 CHECK_ACCESS(_res_conv_18_ptr);
10205                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
10206                 FREE((void*)_res_conv_18);
10207                 _res_constr.data[s] = _res_conv_18_conv;
10208         }
10209         CVec_MessageSendEventZ_free(_res_constr);
10210 }
10211
10212 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
10213         LDKScoringParameters o_conv;
10214         o_conv.inner = (void*)(o & (~1));
10215         o_conv.is_owned = (o & 1) || (o == 0);
10216         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10217         // Warning: we need a move here but no clone is available for LDKScoringParameters
10218         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
10219         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
10220         return (uint64_t)ret_conv;
10221 }
10222
10223 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
10224         LDKDecodeError e_conv;
10225         e_conv.inner = (void*)(e & (~1));
10226         e_conv.is_owned = (e & 1) || (e == 0);
10227         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10228         e_conv = DecodeError_clone(&e_conv);
10229         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
10230         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
10231         return (uint64_t)ret_conv;
10232 }
10233
10234 jboolean  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
10235         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
10236         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
10237         return ret_val;
10238 }
10239
10240 void  __attribute__((visibility("default"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
10241         if ((_res & 1) != 0) return;
10242         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10243         CHECK_ACCESS(_res_ptr);
10244         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
10245         FREE((void*)_res);
10246         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
10247 }
10248
10249 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
10250         LDKScorer o_conv;
10251         o_conv.inner = (void*)(o & (~1));
10252         o_conv.is_owned = (o & 1) || (o == 0);
10253         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10254         // Warning: we need a move here but no clone is available for LDKScorer
10255         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
10256         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
10257         return (uint64_t)ret_conv;
10258 }
10259
10260 uint32_t  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
10261         LDKDecodeError e_conv;
10262         e_conv.inner = (void*)(e & (~1));
10263         e_conv.is_owned = (e & 1) || (e == 0);
10264         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10265         e_conv = DecodeError_clone(&e_conv);
10266         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
10267         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
10268         return (uint64_t)ret_conv;
10269 }
10270
10271 jboolean  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
10272         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
10273         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
10274         return ret_val;
10275 }
10276
10277 void  __attribute__((visibility("default"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
10278         if ((_res & 1) != 0) return;
10279         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10280         CHECK_ACCESS(_res_ptr);
10281         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
10282         FREE((void*)_res);
10283         CResult_ScorerDecodeErrorZ_free(_res_conv);
10284 }
10285
10286 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
10287         LDKInitFeatures o_conv;
10288         o_conv.inner = (void*)(o & (~1));
10289         o_conv.is_owned = (o & 1) || (o == 0);
10290         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10291         o_conv = InitFeatures_clone(&o_conv);
10292         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10293         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
10294         return (uint64_t)ret_conv;
10295 }
10296
10297 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
10298         LDKDecodeError e_conv;
10299         e_conv.inner = (void*)(e & (~1));
10300         e_conv.is_owned = (e & 1) || (e == 0);
10301         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10302         e_conv = DecodeError_clone(&e_conv);
10303         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
10304         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
10305         return (uint64_t)ret_conv;
10306 }
10307
10308 jboolean  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
10309         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
10310         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
10311         return ret_val;
10312 }
10313
10314 void  __attribute__((visibility("default"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
10315         if ((_res & 1) != 0) return;
10316         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10317         CHECK_ACCESS(_res_ptr);
10318         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
10319         FREE((void*)_res);
10320         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
10321 }
10322
10323 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
10324         LDKChannelFeatures o_conv;
10325         o_conv.inner = (void*)(o & (~1));
10326         o_conv.is_owned = (o & 1) || (o == 0);
10327         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10328         o_conv = ChannelFeatures_clone(&o_conv);
10329         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10330         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
10331         return (uint64_t)ret_conv;
10332 }
10333
10334 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
10335         LDKDecodeError e_conv;
10336         e_conv.inner = (void*)(e & (~1));
10337         e_conv.is_owned = (e & 1) || (e == 0);
10338         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10339         e_conv = DecodeError_clone(&e_conv);
10340         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
10341         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
10342         return (uint64_t)ret_conv;
10343 }
10344
10345 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
10346         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
10347         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
10348         return ret_val;
10349 }
10350
10351 void  __attribute__((visibility("default"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
10352         if ((_res & 1) != 0) return;
10353         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10354         CHECK_ACCESS(_res_ptr);
10355         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
10356         FREE((void*)_res);
10357         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
10358 }
10359
10360 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
10361         LDKNodeFeatures o_conv;
10362         o_conv.inner = (void*)(o & (~1));
10363         o_conv.is_owned = (o & 1) || (o == 0);
10364         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10365         o_conv = NodeFeatures_clone(&o_conv);
10366         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10367         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
10368         return (uint64_t)ret_conv;
10369 }
10370
10371 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
10372         LDKDecodeError e_conv;
10373         e_conv.inner = (void*)(e & (~1));
10374         e_conv.is_owned = (e & 1) || (e == 0);
10375         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10376         e_conv = DecodeError_clone(&e_conv);
10377         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
10378         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
10379         return (uint64_t)ret_conv;
10380 }
10381
10382 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
10383         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
10384         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
10385         return ret_val;
10386 }
10387
10388 void  __attribute__((visibility("default"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
10389         if ((_res & 1) != 0) return;
10390         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10391         CHECK_ACCESS(_res_ptr);
10392         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
10393         FREE((void*)_res);
10394         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
10395 }
10396
10397 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
10398         LDKInvoiceFeatures o_conv;
10399         o_conv.inner = (void*)(o & (~1));
10400         o_conv.is_owned = (o & 1) || (o == 0);
10401         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10402         o_conv = InvoiceFeatures_clone(&o_conv);
10403         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10404         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
10405         return (uint64_t)ret_conv;
10406 }
10407
10408 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
10409         LDKDecodeError e_conv;
10410         e_conv.inner = (void*)(e & (~1));
10411         e_conv.is_owned = (e & 1) || (e == 0);
10412         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10413         e_conv = DecodeError_clone(&e_conv);
10414         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
10415         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
10416         return (uint64_t)ret_conv;
10417 }
10418
10419 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
10420         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
10421         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
10422         return ret_val;
10423 }
10424
10425 void  __attribute__((visibility("default"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
10426         if ((_res & 1) != 0) return;
10427         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10428         CHECK_ACCESS(_res_ptr);
10429         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
10430         FREE((void*)_res);
10431         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
10432 }
10433
10434 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
10435         LDKChannelTypeFeatures o_conv;
10436         o_conv.inner = (void*)(o & (~1));
10437         o_conv.is_owned = (o & 1) || (o == 0);
10438         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10439         o_conv = ChannelTypeFeatures_clone(&o_conv);
10440         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
10441         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
10442         return (uint64_t)ret_conv;
10443 }
10444
10445 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
10446         LDKDecodeError e_conv;
10447         e_conv.inner = (void*)(e & (~1));
10448         e_conv.is_owned = (e & 1) || (e == 0);
10449         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10450         e_conv = DecodeError_clone(&e_conv);
10451         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
10452         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
10453         return (uint64_t)ret_conv;
10454 }
10455
10456 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
10457         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
10458         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
10459         return ret_val;
10460 }
10461
10462 void  __attribute__((visibility("default"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
10463         if ((_res & 1) != 0) return;
10464         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10465         CHECK_ACCESS(_res_ptr);
10466         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
10467         FREE((void*)_res);
10468         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
10469 }
10470
10471 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
10472         LDKDelayedPaymentOutputDescriptor o_conv;
10473         o_conv.inner = (void*)(o & (~1));
10474         o_conv.is_owned = (o & 1) || (o == 0);
10475         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10476         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
10477         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10478         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10479         return (uint64_t)ret_conv;
10480 }
10481
10482 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
10483         LDKDecodeError e_conv;
10484         e_conv.inner = (void*)(e & (~1));
10485         e_conv.is_owned = (e & 1) || (e == 0);
10486         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10487         e_conv = DecodeError_clone(&e_conv);
10488         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10489         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10490         return (uint64_t)ret_conv;
10491 }
10492
10493 jboolean  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
10494         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
10495         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
10496         return ret_val;
10497 }
10498
10499 void  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
10500         if ((_res & 1) != 0) return;
10501         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10502         CHECK_ACCESS(_res_ptr);
10503         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
10504         FREE((void*)_res);
10505         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10506 }
10507
10508 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
10509         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10510         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
10511         return (uint64_t)ret_conv;
10512 }
10513 int64_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
10514         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
10515         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
10516         return ret_val;
10517 }
10518
10519 uint32_t  __attribute__((visibility("default"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
10520         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10521         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
10522         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10523         return (uint64_t)ret_conv;
10524 }
10525
10526 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
10527         LDKStaticPaymentOutputDescriptor o_conv;
10528         o_conv.inner = (void*)(o & (~1));
10529         o_conv.is_owned = (o & 1) || (o == 0);
10530         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10531         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
10532         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10533         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
10534         return (uint64_t)ret_conv;
10535 }
10536
10537 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
10538         LDKDecodeError e_conv;
10539         e_conv.inner = (void*)(e & (~1));
10540         e_conv.is_owned = (e & 1) || (e == 0);
10541         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10542         e_conv = DecodeError_clone(&e_conv);
10543         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10544         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
10545         return (uint64_t)ret_conv;
10546 }
10547
10548 jboolean  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
10549         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
10550         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
10551         return ret_val;
10552 }
10553
10554 void  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
10555         if ((_res & 1) != 0) return;
10556         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10557         CHECK_ACCESS(_res_ptr);
10558         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
10559         FREE((void*)_res);
10560         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
10561 }
10562
10563 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
10564         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10565         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
10566         return (uint64_t)ret_conv;
10567 }
10568 int64_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
10569         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
10570         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
10571         return ret_val;
10572 }
10573
10574 uint32_t  __attribute__((visibility("default"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
10575         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
10576         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
10577         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
10578         return (uint64_t)ret_conv;
10579 }
10580
10581 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
10582         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10583         CHECK_ACCESS(o_ptr);
10584         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
10585         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
10586         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10587         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
10588         return (uint64_t)ret_conv;
10589 }
10590
10591 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
10592         LDKDecodeError e_conv;
10593         e_conv.inner = (void*)(e & (~1));
10594         e_conv.is_owned = (e & 1) || (e == 0);
10595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10596         e_conv = DecodeError_clone(&e_conv);
10597         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10598         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
10599         return (uint64_t)ret_conv;
10600 }
10601
10602 jboolean  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
10603         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
10604         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
10605         return ret_val;
10606 }
10607
10608 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
10609         if ((_res & 1) != 0) return;
10610         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10611         CHECK_ACCESS(_res_ptr);
10612         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
10613         FREE((void*)_res);
10614         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
10615 }
10616
10617 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
10618         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10619         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
10620         return (uint64_t)ret_conv;
10621 }
10622 int64_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
10623         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
10624         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
10625         return ret_val;
10626 }
10627
10628 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
10629         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
10630         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
10631         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
10632         return (uint64_t)ret_conv;
10633 }
10634
10635 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_ok() {
10636         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10637         *ret_conv = CResult_NoneNoneZ_ok();
10638         return (uint64_t)ret_conv;
10639 }
10640
10641 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_err() {
10642         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10643         *ret_conv = CResult_NoneNoneZ_err();
10644         return (uint64_t)ret_conv;
10645 }
10646
10647 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10648         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10649         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10650         return ret_val;
10651 }
10652
10653 void  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10654         if ((_res & 1) != 0) return;
10655         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10656         CHECK_ACCESS(_res_ptr);
10657         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10658         FREE((void*)_res);
10659         CResult_NoneNoneZ_free(_res_conv);
10660 }
10661
10662 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10663         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10664         *ret_conv = CResult_NoneNoneZ_clone(arg);
10665         return (uint64_t)ret_conv;
10666 }
10667 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10668         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10669         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10670         return ret_val;
10671 }
10672
10673 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10674         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10675         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10676         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10677         return (uint64_t)ret_conv;
10678 }
10679
10680 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
10681         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10682         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
10683         return ((uint64_t)ret_conv);
10684 }
10685 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
10686         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
10687         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
10688         return ret_val;
10689 }
10690
10691 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
10692         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
10693         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10694         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
10695         return ((uint64_t)ret_conv);
10696 }
10697
10698 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
10699         LDKSignature a_ref;
10700         CHECK(*((uint32_t*)a) == 64);
10701         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
10702         LDKCVec_SignatureZ b_constr;
10703         b_constr.datalen = *((uint32_t*)b);
10704         if (b_constr.datalen > 0)
10705                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10706         else
10707                 b_constr.data = NULL;
10708         int8_tArray* b_vals = (int8_tArray*)(b + 4);
10709         for (size_t m = 0; m < b_constr.datalen; m++) {
10710                 int8_tArray b_conv_12 = b_vals[m];
10711                 LDKSignature b_conv_12_ref;
10712                 CHECK(*((uint32_t*)b_conv_12) == 64);
10713                 memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
10714                 b_constr.data[m] = b_conv_12_ref;
10715         }
10716         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
10717         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
10718         return ((uint64_t)ret_conv);
10719 }
10720
10721 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
10722         if ((_res & 1) != 0) return;
10723         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10724         CHECK_ACCESS(_res_ptr);
10725         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
10726         FREE((void*)_res);
10727         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
10728 }
10729
10730 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
10731         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10732         CHECK_ACCESS(o_ptr);
10733         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
10734         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
10735         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10736         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
10737         return (uint64_t)ret_conv;
10738 }
10739
10740 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
10741         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10742         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
10743         return (uint64_t)ret_conv;
10744 }
10745
10746 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
10747         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
10748         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
10749         return ret_val;
10750 }
10751
10752 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
10753         if ((_res & 1) != 0) return;
10754         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10755         CHECK_ACCESS(_res_ptr);
10756         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
10757         FREE((void*)_res);
10758         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
10759 }
10760
10761 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
10762         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10763         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
10764         return (uint64_t)ret_conv;
10765 }
10766 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
10767         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
10768         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
10769         return ret_val;
10770 }
10771
10772 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
10773         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
10774         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
10775         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
10776         return (uint64_t)ret_conv;
10777 }
10778
10779 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
10780         LDKSignature o_ref;
10781         CHECK(*((uint32_t*)o) == 64);
10782         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
10783         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10784         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
10785         return (uint64_t)ret_conv;
10786 }
10787
10788 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
10789         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10790         *ret_conv = CResult_SignatureNoneZ_err();
10791         return (uint64_t)ret_conv;
10792 }
10793
10794 jboolean  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
10795         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
10796         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
10797         return ret_val;
10798 }
10799
10800 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
10801         if ((_res & 1) != 0) return;
10802         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10803         CHECK_ACCESS(_res_ptr);
10804         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
10805         FREE((void*)_res);
10806         CResult_SignatureNoneZ_free(_res_conv);
10807 }
10808
10809 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
10810         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10811         *ret_conv = CResult_SignatureNoneZ_clone(arg);
10812         return (uint64_t)ret_conv;
10813 }
10814 int64_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
10815         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
10816         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
10817         return ret_val;
10818 }
10819
10820 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
10821         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
10822         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
10823         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
10824         return (uint64_t)ret_conv;
10825 }
10826
10827 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
10828         void* o_ptr = (void*)(((uint64_t)o) & ~1);
10829         CHECK_ACCESS(o_ptr);
10830         LDKSign o_conv = *(LDKSign*)(o_ptr);
10831         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10832         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
10833         return (uint64_t)ret_conv;
10834 }
10835
10836 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
10837         LDKDecodeError e_conv;
10838         e_conv.inner = (void*)(e & (~1));
10839         e_conv.is_owned = (e & 1) || (e == 0);
10840         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10841         e_conv = DecodeError_clone(&e_conv);
10842         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10843         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
10844         return (uint64_t)ret_conv;
10845 }
10846
10847 jboolean  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
10848         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
10849         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
10850         return ret_val;
10851 }
10852
10853 void  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
10854         if ((_res & 1) != 0) return;
10855         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10856         CHECK_ACCESS(_res_ptr);
10857         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
10858         FREE((void*)_res);
10859         CResult_SignDecodeErrorZ_free(_res_conv);
10860 }
10861
10862 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
10863         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10864         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
10865         return (uint64_t)ret_conv;
10866 }
10867 int64_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
10868         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
10869         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
10870         return ret_val;
10871 }
10872
10873 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
10874         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
10875         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
10876         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
10877         return (uint64_t)ret_conv;
10878 }
10879
10880 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
10881         LDKCVec_u8Z _res_ref;
10882         _res_ref.datalen = *((uint32_t*)_res);
10883         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
10884         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
10885         CVec_u8Z_free(_res_ref);
10886 }
10887
10888 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray arg) {
10889         LDKRecoverableSignature arg_ref;
10890         CHECK(*((uint32_t*)arg) == 68);
10891         memcpy(arg_ref.serialized_form, (uint8_t*)(arg + 4), 68);
10892         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10893         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
10894         return (uint64_t)ret_conv;
10895 }
10896
10897 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_err() {
10898         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10899         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
10900         return (uint64_t)ret_conv;
10901 }
10902
10903 jboolean  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
10904         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
10905         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
10906         return ret_val;
10907 }
10908
10909 void  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
10910         if ((_res & 1) != 0) return;
10911         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10912         CHECK_ACCESS(_res_ptr);
10913         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
10914         FREE((void*)_res);
10915         CResult_RecoverableSignatureNoneZ_free(_res_conv);
10916 }
10917
10918 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
10919         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10920         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
10921         return (uint64_t)ret_conv;
10922 }
10923 int64_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
10924         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
10925         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
10926         return ret_val;
10927 }
10928
10929 uint32_t  __attribute__((visibility("default"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
10930         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
10931         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
10932         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
10933         return (uint64_t)ret_conv;
10934 }
10935
10936 void  __attribute__((visibility("default"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
10937         LDKCVec_CVec_u8ZZ _res_constr;
10938         _res_constr.datalen = *((uint32_t*)_res);
10939         if (_res_constr.datalen > 0)
10940                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10941         else
10942                 _res_constr.data = NULL;
10943         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
10944         for (size_t m = 0; m < _res_constr.datalen; m++) {
10945                 int8_tArray _res_conv_12 = _res_vals[m];
10946                 LDKCVec_u8Z _res_conv_12_ref;
10947                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
10948                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
10949                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
10950                 _res_constr.data[m] = _res_conv_12_ref;
10951         }
10952         CVec_CVec_u8ZZ_free(_res_constr);
10953 }
10954
10955 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
10956         LDKCVec_CVec_u8ZZ o_constr;
10957         o_constr.datalen = *((uint32_t*)o);
10958         if (o_constr.datalen > 0)
10959                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
10960         else
10961                 o_constr.data = NULL;
10962         int8_tArray* o_vals = (int8_tArray*)(o + 4);
10963         for (size_t m = 0; m < o_constr.datalen; m++) {
10964                 int8_tArray o_conv_12 = o_vals[m];
10965                 LDKCVec_u8Z o_conv_12_ref;
10966                 o_conv_12_ref.datalen = *((uint32_t*)o_conv_12);
10967                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
10968                 memcpy(o_conv_12_ref.data, (uint8_t*)(o_conv_12 + 4), o_conv_12_ref.datalen);
10969                 o_constr.data[m] = o_conv_12_ref;
10970         }
10971         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10972         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
10973         return (uint64_t)ret_conv;
10974 }
10975
10976 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
10977         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10978         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
10979         return (uint64_t)ret_conv;
10980 }
10981
10982 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
10983         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
10984         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
10985         return ret_val;
10986 }
10987
10988 void  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
10989         if ((_res & 1) != 0) return;
10990         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
10991         CHECK_ACCESS(_res_ptr);
10992         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
10993         FREE((void*)_res);
10994         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
10995 }
10996
10997 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
10998         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
10999         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
11000         return (uint64_t)ret_conv;
11001 }
11002 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
11003         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
11004         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
11005         return ret_val;
11006 }
11007
11008 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
11009         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
11010         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
11011         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
11012         return (uint64_t)ret_conv;
11013 }
11014
11015 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
11016         LDKInMemorySigner o_conv;
11017         o_conv.inner = (void*)(o & (~1));
11018         o_conv.is_owned = (o & 1) || (o == 0);
11019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11020         o_conv = InMemorySigner_clone(&o_conv);
11021         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11022         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
11023         return (uint64_t)ret_conv;
11024 }
11025
11026 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
11027         LDKDecodeError e_conv;
11028         e_conv.inner = (void*)(e & (~1));
11029         e_conv.is_owned = (e & 1) || (e == 0);
11030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11031         e_conv = DecodeError_clone(&e_conv);
11032         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11033         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
11034         return (uint64_t)ret_conv;
11035 }
11036
11037 jboolean  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
11038         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
11039         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
11040         return ret_val;
11041 }
11042
11043 void  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
11044         if ((_res & 1) != 0) return;
11045         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11046         CHECK_ACCESS(_res_ptr);
11047         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
11048         FREE((void*)_res);
11049         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
11050 }
11051
11052 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
11053         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11054         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
11055         return (uint64_t)ret_conv;
11056 }
11057 int64_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
11058         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
11059         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
11060         return ret_val;
11061 }
11062
11063 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
11064         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
11065         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
11066         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
11067         return (uint64_t)ret_conv;
11068 }
11069
11070 void  __attribute__((visibility("default"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
11071         LDKCVec_TxOutZ _res_constr;
11072         _res_constr.datalen = *((uint32_t*)_res);
11073         if (_res_constr.datalen > 0)
11074                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
11075         else
11076                 _res_constr.data = NULL;
11077         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11078         for (size_t h = 0; h < _res_constr.datalen; h++) {
11079                 uint32_t _res_conv_7 = _res_vals[h];
11080                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
11081                 CHECK_ACCESS(_res_conv_7_ptr);
11082                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
11083                 FREE((void*)_res_conv_7);
11084                 _res_constr.data[h] = _res_conv_7_conv;
11085         }
11086         CVec_TxOutZ_free(_res_constr);
11087 }
11088
11089 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
11090         LDKTransaction o_ref;
11091         o_ref.datalen = *((uint32_t*)o);
11092         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
11093         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
11094         o_ref.data_is_owned = true;
11095         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11096         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
11097         return (uint64_t)ret_conv;
11098 }
11099
11100 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_err() {
11101         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11102         *ret_conv = CResult_TransactionNoneZ_err();
11103         return (uint64_t)ret_conv;
11104 }
11105
11106 jboolean  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
11107         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
11108         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
11109         return ret_val;
11110 }
11111
11112 void  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
11113         if ((_res & 1) != 0) return;
11114         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11115         CHECK_ACCESS(_res_ptr);
11116         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
11117         FREE((void*)_res);
11118         CResult_TransactionNoneZ_free(_res_conv);
11119 }
11120
11121 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
11122         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11123         *ret_conv = CResult_TransactionNoneZ_clone(arg);
11124         return (uint64_t)ret_conv;
11125 }
11126 int64_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
11127         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
11128         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
11129         return ret_val;
11130 }
11131
11132 uint32_t  __attribute__((visibility("default"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
11133         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
11134         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
11135         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
11136         return (uint64_t)ret_conv;
11137 }
11138
11139 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
11140         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
11141         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
11142         return ((uint64_t)ret_conv);
11143 }
11144 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
11145         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
11146         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
11147         return ret_val;
11148 }
11149
11150 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
11151         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
11152         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
11153         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
11154         return ((uint64_t)ret_conv);
11155 }
11156
11157 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
11158         LDKThirtyTwoBytes a_ref;
11159         CHECK(*((uint32_t*)a) == 32);
11160         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11161         LDKChannelMonitor b_conv;
11162         b_conv.inner = (void*)(b & (~1));
11163         b_conv.is_owned = (b & 1) || (b == 0);
11164         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
11165         b_conv = ChannelMonitor_clone(&b_conv);
11166         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
11167         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
11168         return ((uint64_t)ret_conv);
11169 }
11170
11171 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
11172         if ((_res & 1) != 0) return;
11173         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11174         CHECK_ACCESS(_res_ptr);
11175         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
11176         FREE((void*)_res);
11177         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
11178 }
11179
11180 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_BlockHashChannelMonitorZZ_free(uint32_tArray _res) {
11181         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
11182         _res_constr.datalen = *((uint32_t*)_res);
11183         if (_res_constr.datalen > 0)
11184                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
11185         else
11186                 _res_constr.data = NULL;
11187         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11188         for (size_t j = 0; j < _res_constr.datalen; j++) {
11189                 uint32_t _res_conv_35 = _res_vals[j];
11190                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
11191                 CHECK_ACCESS(_res_conv_35_ptr);
11192                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
11193                 FREE((void*)_res_conv_35);
11194                 _res_constr.data[j] = _res_conv_35_conv;
11195         }
11196         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
11197 }
11198
11199 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(uint32_tArray o) {
11200         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
11201         o_constr.datalen = *((uint32_t*)o);
11202         if (o_constr.datalen > 0)
11203                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
11204         else
11205                 o_constr.data = NULL;
11206         uint32_t* o_vals = (uint32_t*)(o + 4);
11207         for (size_t j = 0; j < o_constr.datalen; j++) {
11208                 uint32_t o_conv_35 = o_vals[j];
11209                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
11210                 CHECK_ACCESS(o_conv_35_ptr);
11211                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
11212                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
11213                 o_constr.data[j] = o_conv_35_conv;
11214         }
11215         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11216         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
11217         return (uint64_t)ret_conv;
11218 }
11219
11220 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(uint32_t e) {
11221         LDKIOError e_conv = LDKIOError_from_js(e);
11222         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11223         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
11224         return (uint64_t)ret_conv;
11225 }
11226
11227 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(uint32_t o) {
11228         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
11229         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
11230         return ret_val;
11231 }
11232
11233 void  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(uint32_t _res) {
11234         if ((_res & 1) != 0) return;
11235         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11236         CHECK_ACCESS(_res_ptr);
11237         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
11238         FREE((void*)_res);
11239         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
11240 }
11241
11242 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
11243         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11244         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
11245         return (uint64_t)ret_conv;
11246 }
11247 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(uint32_t arg) {
11248         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
11249         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
11250         return ret_val;
11251 }
11252
11253 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(uint32_t orig) {
11254         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
11255         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
11256         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
11257         return (uint64_t)ret_conv;
11258 }
11259
11260 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_some(int16_t o) {
11261         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11262         *ret_copy = COption_u16Z_some(o);
11263         uint64_t ret_ref = (uint64_t)ret_copy;
11264         return ret_ref;
11265 }
11266
11267 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_none() {
11268         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11269         *ret_copy = COption_u16Z_none();
11270         uint64_t ret_ref = (uint64_t)ret_copy;
11271         return ret_ref;
11272 }
11273
11274 void  __attribute__((visibility("default"))) TS_COption_u16Z_free(uint32_t _res) {
11275         if ((_res & 1) != 0) return;
11276         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11277         CHECK_ACCESS(_res_ptr);
11278         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
11279         FREE((void*)_res);
11280         COption_u16Z_free(_res_conv);
11281 }
11282
11283 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
11284         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11285         *ret_copy = COption_u16Z_clone(arg);
11286 uint64_t ret_ref = (uint64_t)ret_copy;
11287         return ret_ref;
11288 }
11289 int64_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
11290         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
11291         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
11292         return ret_val;
11293 }
11294
11295 uint32_t  __attribute__((visibility("default"))) TS_COption_u16Z_clone(uint32_t orig) {
11296         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
11297         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
11298         *ret_copy = COption_u16Z_clone(orig_conv);
11299         uint64_t ret_ref = (uint64_t)ret_copy;
11300         return ret_ref;
11301 }
11302
11303 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
11304         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11305         *ret_conv = CResult_NoneAPIErrorZ_ok();
11306         return (uint64_t)ret_conv;
11307 }
11308
11309 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
11310         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11311         CHECK_ACCESS(e_ptr);
11312         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11313         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11314         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11315         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
11316         return (uint64_t)ret_conv;
11317 }
11318
11319 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
11320         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
11321         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
11322         return ret_val;
11323 }
11324
11325 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
11326         if ((_res & 1) != 0) return;
11327         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11328         CHECK_ACCESS(_res_ptr);
11329         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
11330         FREE((void*)_res);
11331         CResult_NoneAPIErrorZ_free(_res_conv);
11332 }
11333
11334 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
11335         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11336         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
11337         return (uint64_t)ret_conv;
11338 }
11339 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
11340         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
11341         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
11342         return ret_val;
11343 }
11344
11345 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
11346         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
11347         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
11348         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
11349         return (uint64_t)ret_conv;
11350 }
11351
11352 void  __attribute__((visibility("default"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
11353         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
11354         _res_constr.datalen = *((uint32_t*)_res);
11355         if (_res_constr.datalen > 0)
11356                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
11357         else
11358                 _res_constr.data = NULL;
11359         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11360         for (size_t w = 0; w < _res_constr.datalen; w++) {
11361                 uint32_t _res_conv_22 = _res_vals[w];
11362                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
11363                 CHECK_ACCESS(_res_conv_22_ptr);
11364                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
11365                 FREE((void*)_res_conv_22);
11366                 _res_constr.data[w] = _res_conv_22_conv;
11367         }
11368         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
11369 }
11370
11371 void  __attribute__((visibility("default"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
11372         LDKCVec_APIErrorZ _res_constr;
11373         _res_constr.datalen = *((uint32_t*)_res);
11374         if (_res_constr.datalen > 0)
11375                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
11376         else
11377                 _res_constr.data = NULL;
11378         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11379         for (size_t k = 0; k < _res_constr.datalen; k++) {
11380                 uint32_t _res_conv_10 = _res_vals[k];
11381                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
11382                 CHECK_ACCESS(_res_conv_10_ptr);
11383                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
11384                 FREE((void*)_res_conv_10);
11385                 _res_constr.data[k] = _res_conv_10_conv;
11386         }
11387         CVec_APIErrorZ_free(_res_constr);
11388 }
11389
11390 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
11391         LDKThirtyTwoBytes o_ref;
11392         CHECK(*((uint32_t*)o) == 32);
11393         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11394         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11395         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
11396         return (uint64_t)ret_conv;
11397 }
11398
11399 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
11400         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11401         CHECK_ACCESS(e_ptr);
11402         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11403         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11404         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11405         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
11406         return (uint64_t)ret_conv;
11407 }
11408
11409 jboolean  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
11410         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
11411         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
11412         return ret_val;
11413 }
11414
11415 void  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
11416         if ((_res & 1) != 0) return;
11417         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11418         CHECK_ACCESS(_res_ptr);
11419         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
11420         FREE((void*)_res);
11421         CResult__u832APIErrorZ_free(_res_conv);
11422 }
11423
11424 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
11425         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11426         *ret_conv = CResult__u832APIErrorZ_clone(arg);
11427         return (uint64_t)ret_conv;
11428 }
11429 int64_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
11430         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
11431         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
11432         return ret_val;
11433 }
11434
11435 uint32_t  __attribute__((visibility("default"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
11436         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
11437         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
11438         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
11439         return (uint64_t)ret_conv;
11440 }
11441
11442 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
11443         LDKThirtyTwoBytes o_ref;
11444         CHECK(*((uint32_t*)o) == 32);
11445         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11446         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11447         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
11448         return (uint64_t)ret_conv;
11449 }
11450
11451 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
11452         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11453         CHECK_ACCESS(e_ptr);
11454         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
11455         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11456         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11457         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
11458         return (uint64_t)ret_conv;
11459 }
11460
11461 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
11462         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
11463         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
11464         return ret_val;
11465 }
11466
11467 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
11468         if ((_res & 1) != 0) return;
11469         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11470         CHECK_ACCESS(_res_ptr);
11471         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
11472         FREE((void*)_res);
11473         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
11474 }
11475
11476 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
11477         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11478         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
11479         return (uint64_t)ret_conv;
11480 }
11481 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
11482         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
11483         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
11484         return ret_val;
11485 }
11486
11487 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
11488         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
11489         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
11490         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
11491         return (uint64_t)ret_conv;
11492 }
11493
11494 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
11495         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11496         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
11497         return (uint64_t)ret_conv;
11498 }
11499
11500 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
11501         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11502         CHECK_ACCESS(e_ptr);
11503         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
11504         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11505         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11506         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
11507         return (uint64_t)ret_conv;
11508 }
11509
11510 jboolean  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
11511         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
11512         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
11513         return ret_val;
11514 }
11515
11516 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
11517         if ((_res & 1) != 0) return;
11518         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11519         CHECK_ACCESS(_res_ptr);
11520         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
11521         FREE((void*)_res);
11522         CResult_NonePaymentSendFailureZ_free(_res_conv);
11523 }
11524
11525 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
11526         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11527         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
11528         return (uint64_t)ret_conv;
11529 }
11530 int64_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
11531         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
11532         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
11533         return ret_val;
11534 }
11535
11536 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
11537         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
11538         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
11539         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
11540         return (uint64_t)ret_conv;
11541 }
11542
11543 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
11544         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
11545         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
11546         return ((uint64_t)ret_conv);
11547 }
11548 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
11549         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
11550         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
11551         return ret_val;
11552 }
11553
11554 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
11555         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
11556         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
11557         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
11558         return ((uint64_t)ret_conv);
11559 }
11560
11561 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
11562         LDKThirtyTwoBytes a_ref;
11563         CHECK(*((uint32_t*)a) == 32);
11564         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11565         LDKThirtyTwoBytes b_ref;
11566         CHECK(*((uint32_t*)b) == 32);
11567         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
11568         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
11569         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
11570         return ((uint64_t)ret_conv);
11571 }
11572
11573 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
11574         if ((_res & 1) != 0) return;
11575         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11576         CHECK_ACCESS(_res_ptr);
11577         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
11578         FREE((void*)_res);
11579         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
11580 }
11581
11582 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
11583         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11584         CHECK_ACCESS(o_ptr);
11585         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
11586         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
11587         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11588         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
11589         return (uint64_t)ret_conv;
11590 }
11591
11592 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
11593         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11594         CHECK_ACCESS(e_ptr);
11595         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
11596         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
11597         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11598         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
11599         return (uint64_t)ret_conv;
11600 }
11601
11602 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
11603         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
11604         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
11605         return ret_val;
11606 }
11607
11608 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
11609         if ((_res & 1) != 0) return;
11610         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11611         CHECK_ACCESS(_res_ptr);
11612         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
11613         FREE((void*)_res);
11614         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
11615 }
11616
11617 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
11618         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11619         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
11620         return (uint64_t)ret_conv;
11621 }
11622 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
11623         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
11624         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
11625         return ret_val;
11626 }
11627
11628 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
11629         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
11630         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
11631         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
11632         return (uint64_t)ret_conv;
11633 }
11634
11635 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
11636         LDKCVec_NetAddressZ _res_constr;
11637         _res_constr.datalen = *((uint32_t*)_res);
11638         if (_res_constr.datalen > 0)
11639                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
11640         else
11641                 _res_constr.data = NULL;
11642         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11643         for (size_t m = 0; m < _res_constr.datalen; m++) {
11644                 uint32_t _res_conv_12 = _res_vals[m];
11645                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
11646                 CHECK_ACCESS(_res_conv_12_ptr);
11647                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
11648                 FREE((void*)_res_conv_12);
11649                 _res_constr.data[m] = _res_conv_12_conv;
11650         }
11651         CVec_NetAddressZ_free(_res_constr);
11652 }
11653
11654 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
11655         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11656         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
11657         return ((uint64_t)ret_conv);
11658 }
11659 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
11660         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
11661         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
11662         return ret_val;
11663 }
11664
11665 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
11666         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
11667         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11668         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
11669         return ((uint64_t)ret_conv);
11670 }
11671
11672 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
11673         LDKThirtyTwoBytes a_ref;
11674         CHECK(*((uint32_t*)a) == 32);
11675         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11676         LDKThirtyTwoBytes b_ref;
11677         CHECK(*((uint32_t*)b) == 32);
11678         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
11679         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
11680         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
11681         return ((uint64_t)ret_conv);
11682 }
11683
11684 void  __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
11685         if ((_res & 1) != 0) return;
11686         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11687         CHECK_ACCESS(_res_ptr);
11688         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
11689         FREE((void*)_res);
11690         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
11691 }
11692
11693 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
11694         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11695         CHECK_ACCESS(o_ptr);
11696         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
11697         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)o) & ~1));
11698         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
11699         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
11700         return (uint64_t)ret_conv;
11701 }
11702
11703 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
11704         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
11705         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
11706         return (uint64_t)ret_conv;
11707 }
11708
11709 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
11710         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
11711         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
11712         return ret_val;
11713 }
11714
11715 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
11716         if ((_res & 1) != 0) return;
11717         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11718         CHECK_ACCESS(_res_ptr);
11719         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
11720         FREE((void*)_res);
11721         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
11722 }
11723
11724 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
11725         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
11726         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
11727         return (uint64_t)ret_conv;
11728 }
11729 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
11730         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
11731         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
11732         return ret_val;
11733 }
11734
11735 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
11736         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
11737         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
11738         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
11739         return (uint64_t)ret_conv;
11740 }
11741
11742 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
11743         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11744         CHECK_ACCESS(o_ptr);
11745         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
11746         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uint64_t)o) & ~1));
11747         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
11748         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
11749         return (uint64_t)ret_conv;
11750 }
11751
11752 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
11753         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11754         CHECK_ACCESS(e_ptr);
11755         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11756         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11757         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
11758         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
11759         return (uint64_t)ret_conv;
11760 }
11761
11762 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
11763         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
11764         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
11765         return ret_val;
11766 }
11767
11768 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
11769         if ((_res & 1) != 0) return;
11770         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11771         CHECK_ACCESS(_res_ptr);
11772         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
11773         FREE((void*)_res);
11774         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
11775 }
11776
11777 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
11778         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
11779         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
11780         return (uint64_t)ret_conv;
11781 }
11782 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
11783         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
11784         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
11785         return ret_val;
11786 }
11787
11788 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
11789         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
11790         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
11791         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
11792         return (uint64_t)ret_conv;
11793 }
11794
11795 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
11796         LDKThirtyTwoBytes o_ref;
11797         CHECK(*((uint32_t*)o) == 32);
11798         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11799         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
11800         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
11801         return (uint64_t)ret_conv;
11802 }
11803
11804 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretNoneZ_err() {
11805         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
11806         *ret_conv = CResult_PaymentSecretNoneZ_err();
11807         return (uint64_t)ret_conv;
11808 }
11809
11810 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
11811         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
11812         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
11813         return ret_val;
11814 }
11815
11816 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
11817         if ((_res & 1) != 0) return;
11818         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11819         CHECK_ACCESS(_res_ptr);
11820         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
11821         FREE((void*)_res);
11822         CResult_PaymentSecretNoneZ_free(_res_conv);
11823 }
11824
11825 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
11826         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
11827         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
11828         return (uint64_t)ret_conv;
11829 }
11830 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
11831         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
11832         int64_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
11833         return ret_val;
11834 }
11835
11836 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
11837         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
11838         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
11839         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
11840         return (uint64_t)ret_conv;
11841 }
11842
11843 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
11844         LDKThirtyTwoBytes o_ref;
11845         CHECK(*((uint32_t*)o) == 32);
11846         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11847         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11848         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
11849         return (uint64_t)ret_conv;
11850 }
11851
11852 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
11853         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11854         CHECK_ACCESS(e_ptr);
11855         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11856         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11857         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11858         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
11859         return (uint64_t)ret_conv;
11860 }
11861
11862 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
11863         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
11864         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
11865         return ret_val;
11866 }
11867
11868 void  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
11869         if ((_res & 1) != 0) return;
11870         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11871         CHECK_ACCESS(_res_ptr);
11872         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
11873         FREE((void*)_res);
11874         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
11875 }
11876
11877 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
11878         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11879         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
11880         return (uint64_t)ret_conv;
11881 }
11882 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
11883         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
11884         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
11885         return ret_val;
11886 }
11887
11888 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
11889         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
11890         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
11891         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
11892         return (uint64_t)ret_conv;
11893 }
11894
11895 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
11896         LDKThirtyTwoBytes o_ref;
11897         CHECK(*((uint32_t*)o) == 32);
11898         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
11899         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
11900         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
11901         return (uint64_t)ret_conv;
11902 }
11903
11904 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
11905         void* e_ptr = (void*)(((uint64_t)e) & ~1);
11906         CHECK_ACCESS(e_ptr);
11907         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
11908         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
11909         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
11910         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
11911         return (uint64_t)ret_conv;
11912 }
11913
11914 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
11915         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
11916         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
11917         return ret_val;
11918 }
11919
11920 void  __attribute__((visibility("default"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
11921         if ((_res & 1) != 0) return;
11922         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11923         CHECK_ACCESS(_res_ptr);
11924         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
11925         FREE((void*)_res);
11926         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
11927 }
11928
11929 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
11930         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
11931         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
11932         return (uint64_t)ret_conv;
11933 }
11934 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
11935         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
11936         int64_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
11937         return ret_val;
11938 }
11939
11940 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
11941         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
11942         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
11943         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
11944         return (uint64_t)ret_conv;
11945 }
11946
11947 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
11948         LDKCVec_ChannelMonitorZ _res_constr;
11949         _res_constr.datalen = *((uint32_t*)_res);
11950         if (_res_constr.datalen > 0)
11951                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
11952         else
11953                 _res_constr.data = NULL;
11954         uint32_t* _res_vals = (uint32_t*)(_res + 4);
11955         for (size_t q = 0; q < _res_constr.datalen; q++) {
11956                 uint32_t _res_conv_16 = _res_vals[q];
11957                 LDKChannelMonitor _res_conv_16_conv;
11958                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11959                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11960                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11961                 _res_constr.data[q] = _res_conv_16_conv;
11962         }
11963         CVec_ChannelMonitorZ_free(_res_constr);
11964 }
11965
11966 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
11967         LDKThirtyTwoBytes a_ref;
11968         CHECK(*((uint32_t*)a) == 32);
11969         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
11970         LDKChannelManager b_conv;
11971         b_conv.inner = (void*)(b & (~1));
11972         b_conv.is_owned = (b & 1) || (b == 0);
11973         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
11974         // Warning: we need a move here but no clone is available for LDKChannelManager
11975         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
11976         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
11977         return ((uint64_t)ret_conv);
11978 }
11979
11980 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
11981         if ((_res & 1) != 0) return;
11982         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11983         CHECK_ACCESS(_res_ptr);
11984         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
11985         FREE((void*)_res);
11986         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
11987 }
11988
11989 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
11990         void* o_ptr = (void*)(((uint64_t)o) & ~1);
11991         CHECK_ACCESS(o_ptr);
11992         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
11993         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
11994         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
11995         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
11996         return (uint64_t)ret_conv;
11997 }
11998
11999 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
12000         LDKDecodeError e_conv;
12001         e_conv.inner = (void*)(e & (~1));
12002         e_conv.is_owned = (e & 1) || (e == 0);
12003         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12004         e_conv = DecodeError_clone(&e_conv);
12005         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
12006         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
12007         return (uint64_t)ret_conv;
12008 }
12009
12010 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
12011         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
12012         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
12013         return ret_val;
12014 }
12015
12016 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
12017         if ((_res & 1) != 0) return;
12018         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12019         CHECK_ACCESS(_res_ptr);
12020         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
12021         FREE((void*)_res);
12022         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
12023 }
12024
12025 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
12026         LDKChannelConfig o_conv;
12027         o_conv.inner = (void*)(o & (~1));
12028         o_conv.is_owned = (o & 1) || (o == 0);
12029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12030         o_conv = ChannelConfig_clone(&o_conv);
12031         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12032         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
12033         return (uint64_t)ret_conv;
12034 }
12035
12036 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
12037         LDKDecodeError e_conv;
12038         e_conv.inner = (void*)(e & (~1));
12039         e_conv.is_owned = (e & 1) || (e == 0);
12040         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12041         e_conv = DecodeError_clone(&e_conv);
12042         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12043         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
12044         return (uint64_t)ret_conv;
12045 }
12046
12047 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
12048         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
12049         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
12050         return ret_val;
12051 }
12052
12053 void  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
12054         if ((_res & 1) != 0) return;
12055         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12056         CHECK_ACCESS(_res_ptr);
12057         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
12058         FREE((void*)_res);
12059         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
12060 }
12061
12062 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
12063         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12064         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
12065         return (uint64_t)ret_conv;
12066 }
12067 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
12068         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
12069         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
12070         return ret_val;
12071 }
12072
12073 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
12074         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
12075         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
12076         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
12077         return (uint64_t)ret_conv;
12078 }
12079
12080 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
12081         LDKOutPoint o_conv;
12082         o_conv.inner = (void*)(o & (~1));
12083         o_conv.is_owned = (o & 1) || (o == 0);
12084         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12085         o_conv = OutPoint_clone(&o_conv);
12086         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12087         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
12088         return (uint64_t)ret_conv;
12089 }
12090
12091 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
12092         LDKDecodeError e_conv;
12093         e_conv.inner = (void*)(e & (~1));
12094         e_conv.is_owned = (e & 1) || (e == 0);
12095         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12096         e_conv = DecodeError_clone(&e_conv);
12097         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12098         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
12099         return (uint64_t)ret_conv;
12100 }
12101
12102 jboolean  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
12103         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
12104         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
12105         return ret_val;
12106 }
12107
12108 void  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
12109         if ((_res & 1) != 0) return;
12110         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12111         CHECK_ACCESS(_res_ptr);
12112         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
12113         FREE((void*)_res);
12114         CResult_OutPointDecodeErrorZ_free(_res_conv);
12115 }
12116
12117 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
12118         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12119         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
12120         return (uint64_t)ret_conv;
12121 }
12122 int64_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
12123         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
12124         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
12125         return ret_val;
12126 }
12127
12128 uint32_t  __attribute__((visibility("default"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
12129         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
12130         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
12131         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
12132         return (uint64_t)ret_conv;
12133 }
12134
12135 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_some(uint32_t o) {
12136         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12137         CHECK_ACCESS(o_ptr);
12138         LDKType o_conv = *(LDKType*)(o_ptr);
12139         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12140         *ret_copy = COption_TypeZ_some(o_conv);
12141         uint64_t ret_ref = (uint64_t)ret_copy;
12142         return ret_ref;
12143 }
12144
12145 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_none() {
12146         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12147         *ret_copy = COption_TypeZ_none();
12148         uint64_t ret_ref = (uint64_t)ret_copy;
12149         return ret_ref;
12150 }
12151
12152 void  __attribute__((visibility("default"))) TS_COption_TypeZ_free(uint32_t _res) {
12153         if ((_res & 1) != 0) return;
12154         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12155         CHECK_ACCESS(_res_ptr);
12156         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
12157         FREE((void*)_res);
12158         COption_TypeZ_free(_res_conv);
12159 }
12160
12161 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
12162         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12163         *ret_copy = COption_TypeZ_clone(arg);
12164 uint64_t ret_ref = (uint64_t)ret_copy;
12165         return ret_ref;
12166 }
12167 int64_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
12168         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
12169         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
12170         return ret_val;
12171 }
12172
12173 uint32_t  __attribute__((visibility("default"))) TS_COption_TypeZ_clone(uint32_t orig) {
12174         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
12175         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
12176         *ret_copy = COption_TypeZ_clone(orig_conv);
12177         uint64_t ret_ref = (uint64_t)ret_copy;
12178         return ret_ref;
12179 }
12180
12181 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
12182         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12183         CHECK_ACCESS(o_ptr);
12184         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
12185         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
12186         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12187         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
12188         return (uint64_t)ret_conv;
12189 }
12190
12191 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
12192         LDKDecodeError e_conv;
12193         e_conv.inner = (void*)(e & (~1));
12194         e_conv.is_owned = (e & 1) || (e == 0);
12195         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12196         e_conv = DecodeError_clone(&e_conv);
12197         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12198         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
12199         return (uint64_t)ret_conv;
12200 }
12201
12202 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
12203         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
12204         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
12205         return ret_val;
12206 }
12207
12208 void  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
12209         if ((_res & 1) != 0) return;
12210         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12211         CHECK_ACCESS(_res_ptr);
12212         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
12213         FREE((void*)_res);
12214         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
12215 }
12216
12217 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
12218         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12219         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
12220         return (uint64_t)ret_conv;
12221 }
12222 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
12223         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
12224         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
12225         return ret_val;
12226 }
12227
12228 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
12229         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
12230         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
12231         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
12232         return (uint64_t)ret_conv;
12233 }
12234
12235 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
12236         LDKThirtyTwoBytes o_ref;
12237         CHECK(*((uint32_t*)o) == 32);
12238         memcpy(o_ref.data, (uint8_t*)(o + 4), 32);
12239         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
12240         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
12241         return (uint64_t)ret_conv;
12242 }
12243
12244 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
12245         void* e_ptr = (void*)(((uint64_t)e) & ~1);
12246         CHECK_ACCESS(e_ptr);
12247         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
12248         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
12249         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
12250         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
12251         return (uint64_t)ret_conv;
12252 }
12253
12254 jboolean  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
12255         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
12256         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
12257         return ret_val;
12258 }
12259
12260 void  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
12261         if ((_res & 1) != 0) return;
12262         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12263         CHECK_ACCESS(_res_ptr);
12264         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
12265         FREE((void*)_res);
12266         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
12267 }
12268
12269 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
12270         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
12271         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
12272         return (uint64_t)ret_conv;
12273 }
12274 int64_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
12275         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
12276         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
12277         return ret_val;
12278 }
12279
12280 uint32_t  __attribute__((visibility("default"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
12281         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
12282         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
12283         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
12284         return (uint64_t)ret_conv;
12285 }
12286
12287 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_ok(uint32_t o) {
12288         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
12289         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12290         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
12291         return (uint64_t)ret_conv;
12292 }
12293
12294 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_err() {
12295         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12296         *ret_conv = CResult_SiPrefixNoneZ_err();
12297         return (uint64_t)ret_conv;
12298 }
12299
12300 jboolean  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_is_ok(uint32_t o) {
12301         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
12302         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
12303         return ret_val;
12304 }
12305
12306 void  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_free(uint32_t _res) {
12307         if ((_res & 1) != 0) return;
12308         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12309         CHECK_ACCESS(_res_ptr);
12310         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
12311         FREE((void*)_res);
12312         CResult_SiPrefixNoneZ_free(_res_conv);
12313 }
12314
12315 static inline uint64_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
12316         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12317         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
12318         return (uint64_t)ret_conv;
12319 }
12320 int64_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone_ptr(uint32_t arg) {
12321         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
12322         int64_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
12323         return ret_val;
12324 }
12325
12326 uint32_t  __attribute__((visibility("default"))) TS_CResult_SiPrefixNoneZ_clone(uint32_t orig) {
12327         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
12328         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
12329         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
12330         return (uint64_t)ret_conv;
12331 }
12332
12333 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_ok(uint32_t o) {
12334         LDKInvoice o_conv;
12335         o_conv.inner = (void*)(o & (~1));
12336         o_conv.is_owned = (o & 1) || (o == 0);
12337         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12338         o_conv = Invoice_clone(&o_conv);
12339         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12340         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
12341         return (uint64_t)ret_conv;
12342 }
12343
12344 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_err() {
12345         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12346         *ret_conv = CResult_InvoiceNoneZ_err();
12347         return (uint64_t)ret_conv;
12348 }
12349
12350 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_is_ok(uint32_t o) {
12351         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
12352         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
12353         return ret_val;
12354 }
12355
12356 void  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_free(uint32_t _res) {
12357         if ((_res & 1) != 0) return;
12358         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12359         CHECK_ACCESS(_res_ptr);
12360         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
12361         FREE((void*)_res);
12362         CResult_InvoiceNoneZ_free(_res_conv);
12363 }
12364
12365 static inline uint64_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
12366         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12367         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
12368         return (uint64_t)ret_conv;
12369 }
12370 int64_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone_ptr(uint32_t arg) {
12371         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
12372         int64_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
12373         return ret_val;
12374 }
12375
12376 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceNoneZ_clone(uint32_t orig) {
12377         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
12378         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
12379         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
12380         return (uint64_t)ret_conv;
12381 }
12382
12383 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_ok(uint32_t o) {
12384         LDKSignedRawInvoice o_conv;
12385         o_conv.inner = (void*)(o & (~1));
12386         o_conv.is_owned = (o & 1) || (o == 0);
12387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12388         o_conv = SignedRawInvoice_clone(&o_conv);
12389         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12390         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
12391         return (uint64_t)ret_conv;
12392 }
12393
12394 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_err() {
12395         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12396         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
12397         return (uint64_t)ret_conv;
12398 }
12399
12400 jboolean  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_is_ok(uint32_t o) {
12401         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
12402         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
12403         return ret_val;
12404 }
12405
12406 void  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_free(uint32_t _res) {
12407         if ((_res & 1) != 0) return;
12408         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12409         CHECK_ACCESS(_res_ptr);
12410         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
12411         FREE((void*)_res);
12412         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
12413 }
12414
12415 static inline uint64_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
12416         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12417         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
12418         return (uint64_t)ret_conv;
12419 }
12420 int64_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone_ptr(uint32_t arg) {
12421         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
12422         int64_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
12423         return ret_val;
12424 }
12425
12426 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignedRawInvoiceNoneZ_clone(uint32_t orig) {
12427         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
12428         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
12429         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
12430         return (uint64_t)ret_conv;
12431 }
12432
12433 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
12434         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12435         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
12436         return ((uint64_t)ret_conv);
12437 }
12438 int64_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
12439         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
12440         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
12441         return ret_val;
12442 }
12443
12444 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
12445         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
12446         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12447         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
12448         return ((uint64_t)ret_conv);
12449 }
12450
12451 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
12452         LDKRawInvoice a_conv;
12453         a_conv.inner = (void*)(a & (~1));
12454         a_conv.is_owned = (a & 1) || (a == 0);
12455         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
12456         a_conv = RawInvoice_clone(&a_conv);
12457         LDKThirtyTwoBytes b_ref;
12458         CHECK(*((uint32_t*)b) == 32);
12459         memcpy(b_ref.data, (uint8_t*)(b + 4), 32);
12460         LDKInvoiceSignature c_conv;
12461         c_conv.inner = (void*)(c & (~1));
12462         c_conv.is_owned = (c & 1) || (c == 0);
12463         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
12464         c_conv = InvoiceSignature_clone(&c_conv);
12465         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
12466         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
12467         return ((uint64_t)ret_conv);
12468 }
12469
12470 void  __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
12471         if ((_res & 1) != 0) return;
12472         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12473         CHECK_ACCESS(_res_ptr);
12474         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
12475         FREE((void*)_res);
12476         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
12477 }
12478
12479 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
12480         LDKPayeePubKey o_conv;
12481         o_conv.inner = (void*)(o & (~1));
12482         o_conv.is_owned = (o & 1) || (o == 0);
12483         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12484         o_conv = PayeePubKey_clone(&o_conv);
12485         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12486         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
12487         return (uint64_t)ret_conv;
12488 }
12489
12490 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
12491         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
12492         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12493         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
12494         return (uint64_t)ret_conv;
12495 }
12496
12497 jboolean  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
12498         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
12499         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
12500         return ret_val;
12501 }
12502
12503 void  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
12504         if ((_res & 1) != 0) return;
12505         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12506         CHECK_ACCESS(_res_ptr);
12507         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
12508         FREE((void*)_res);
12509         CResult_PayeePubKeyErrorZ_free(_res_conv);
12510 }
12511
12512 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
12513         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12514         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
12515         return (uint64_t)ret_conv;
12516 }
12517 int64_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
12518         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
12519         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
12520         return ret_val;
12521 }
12522
12523 uint32_t  __attribute__((visibility("default"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
12524         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
12525         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
12526         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
12527         return (uint64_t)ret_conv;
12528 }
12529
12530 void  __attribute__((visibility("default"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
12531         LDKCVec_PrivateRouteZ _res_constr;
12532         _res_constr.datalen = *((uint32_t*)_res);
12533         if (_res_constr.datalen > 0)
12534                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
12535         else
12536                 _res_constr.data = NULL;
12537         uint32_t* _res_vals = (uint32_t*)(_res + 4);
12538         for (size_t o = 0; o < _res_constr.datalen; o++) {
12539                 uint32_t _res_conv_14 = _res_vals[o];
12540                 LDKPrivateRoute _res_conv_14_conv;
12541                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12542                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12543                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12544                 _res_constr.data[o] = _res_conv_14_conv;
12545         }
12546         CVec_PrivateRouteZ_free(_res_constr);
12547 }
12548
12549 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
12550         LDKPositiveTimestamp o_conv;
12551         o_conv.inner = (void*)(o & (~1));
12552         o_conv.is_owned = (o & 1) || (o == 0);
12553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12554         o_conv = PositiveTimestamp_clone(&o_conv);
12555         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12556         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
12557         return (uint64_t)ret_conv;
12558 }
12559
12560 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
12561         LDKCreationError e_conv = LDKCreationError_from_js(e);
12562         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12563         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
12564         return (uint64_t)ret_conv;
12565 }
12566
12567 jboolean  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
12568         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
12569         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
12570         return ret_val;
12571 }
12572
12573 void  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
12574         if ((_res & 1) != 0) return;
12575         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12576         CHECK_ACCESS(_res_ptr);
12577         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
12578         FREE((void*)_res);
12579         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
12580 }
12581
12582 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
12583         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12584         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
12585         return (uint64_t)ret_conv;
12586 }
12587 int64_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
12588         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
12589         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
12590         return ret_val;
12591 }
12592
12593 uint32_t  __attribute__((visibility("default"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
12594         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
12595         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
12596         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
12597         return (uint64_t)ret_conv;
12598 }
12599
12600 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_ok() {
12601         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12602         *ret_conv = CResult_NoneSemanticErrorZ_ok();
12603         return (uint64_t)ret_conv;
12604 }
12605
12606 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
12607         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
12608         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12609         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
12610         return (uint64_t)ret_conv;
12611 }
12612
12613 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
12614         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
12615         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
12616         return ret_val;
12617 }
12618
12619 void  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
12620         if ((_res & 1) != 0) return;
12621         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12622         CHECK_ACCESS(_res_ptr);
12623         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
12624         FREE((void*)_res);
12625         CResult_NoneSemanticErrorZ_free(_res_conv);
12626 }
12627
12628 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
12629         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12630         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
12631         return (uint64_t)ret_conv;
12632 }
12633 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
12634         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
12635         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
12636         return ret_val;
12637 }
12638
12639 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
12640         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
12641         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
12642         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
12643         return (uint64_t)ret_conv;
12644 }
12645
12646 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
12647         LDKInvoice o_conv;
12648         o_conv.inner = (void*)(o & (~1));
12649         o_conv.is_owned = (o & 1) || (o == 0);
12650         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12651         o_conv = Invoice_clone(&o_conv);
12652         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12653         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
12654         return (uint64_t)ret_conv;
12655 }
12656
12657 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
12658         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
12659         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12660         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
12661         return (uint64_t)ret_conv;
12662 }
12663
12664 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
12665         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
12666         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
12667         return ret_val;
12668 }
12669
12670 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
12671         if ((_res & 1) != 0) return;
12672         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12673         CHECK_ACCESS(_res_ptr);
12674         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
12675         FREE((void*)_res);
12676         CResult_InvoiceSemanticErrorZ_free(_res_conv);
12677 }
12678
12679 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
12680         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12681         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
12682         return (uint64_t)ret_conv;
12683 }
12684 int64_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
12685         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
12686         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
12687         return ret_val;
12688 }
12689
12690 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
12691         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
12692         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
12693         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
12694         return (uint64_t)ret_conv;
12695 }
12696
12697 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
12698         LDKDescription o_conv;
12699         o_conv.inner = (void*)(o & (~1));
12700         o_conv.is_owned = (o & 1) || (o == 0);
12701         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12702         o_conv = Description_clone(&o_conv);
12703         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12704         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
12705         return (uint64_t)ret_conv;
12706 }
12707
12708 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
12709         LDKCreationError e_conv = LDKCreationError_from_js(e);
12710         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12711         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
12712         return (uint64_t)ret_conv;
12713 }
12714
12715 jboolean  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
12716         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
12717         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
12718         return ret_val;
12719 }
12720
12721 void  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
12722         if ((_res & 1) != 0) return;
12723         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12724         CHECK_ACCESS(_res_ptr);
12725         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
12726         FREE((void*)_res);
12727         CResult_DescriptionCreationErrorZ_free(_res_conv);
12728 }
12729
12730 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
12731         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12732         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
12733         return (uint64_t)ret_conv;
12734 }
12735 int64_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
12736         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
12737         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
12738         return ret_val;
12739 }
12740
12741 uint32_t  __attribute__((visibility("default"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
12742         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
12743         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
12744         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
12745         return (uint64_t)ret_conv;
12746 }
12747
12748 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_ok(uint32_t o) {
12749         LDKExpiryTime o_conv;
12750         o_conv.inner = (void*)(o & (~1));
12751         o_conv.is_owned = (o & 1) || (o == 0);
12752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12753         o_conv = ExpiryTime_clone(&o_conv);
12754         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12755         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
12756         return (uint64_t)ret_conv;
12757 }
12758
12759 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_err(uint32_t e) {
12760         LDKCreationError e_conv = LDKCreationError_from_js(e);
12761         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12762         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
12763         return (uint64_t)ret_conv;
12764 }
12765
12766 jboolean  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_is_ok(uint32_t o) {
12767         LDKCResult_ExpiryTimeCreationErrorZ* o_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(o & ~1);
12768         jboolean ret_val = CResult_ExpiryTimeCreationErrorZ_is_ok(o_conv);
12769         return ret_val;
12770 }
12771
12772 void  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_free(uint32_t _res) {
12773         if ((_res & 1) != 0) return;
12774         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12775         CHECK_ACCESS(_res_ptr);
12776         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
12777         FREE((void*)_res);
12778         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
12779 }
12780
12781 static inline uint64_t CResult_ExpiryTimeCreationErrorZ_clone_ptr(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR arg) {
12782         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12783         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(arg);
12784         return (uint64_t)ret_conv;
12785 }
12786 int64_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone_ptr(uint32_t arg) {
12787         LDKCResult_ExpiryTimeCreationErrorZ* arg_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
12788         int64_t ret_val = CResult_ExpiryTimeCreationErrorZ_clone_ptr(arg_conv);
12789         return ret_val;
12790 }
12791
12792 uint32_t  __attribute__((visibility("default"))) TS_CResult_ExpiryTimeCreationErrorZ_clone(uint32_t orig) {
12793         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
12794         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
12795         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
12796         return (uint64_t)ret_conv;
12797 }
12798
12799 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
12800         LDKPrivateRoute o_conv;
12801         o_conv.inner = (void*)(o & (~1));
12802         o_conv.is_owned = (o & 1) || (o == 0);
12803         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12804         o_conv = PrivateRoute_clone(&o_conv);
12805         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12806         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
12807         return (uint64_t)ret_conv;
12808 }
12809
12810 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
12811         LDKCreationError e_conv = LDKCreationError_from_js(e);
12812         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12813         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
12814         return (uint64_t)ret_conv;
12815 }
12816
12817 jboolean  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
12818         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
12819         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
12820         return ret_val;
12821 }
12822
12823 void  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
12824         if ((_res & 1) != 0) return;
12825         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12826         CHECK_ACCESS(_res_ptr);
12827         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
12828         FREE((void*)_res);
12829         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
12830 }
12831
12832 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
12833         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12834         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
12835         return (uint64_t)ret_conv;
12836 }
12837 int64_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
12838         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
12839         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
12840         return ret_val;
12841 }
12842
12843 uint32_t  __attribute__((visibility("default"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
12844         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
12845         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
12846         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
12847         return (uint64_t)ret_conv;
12848 }
12849
12850 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_ok(jstring o) {
12851         LDKStr o_conv = str_ref_to_owned_c(o);
12852         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12853         *ret_conv = CResult_StringErrorZ_ok(o_conv);
12854         return (uint64_t)ret_conv;
12855 }
12856
12857 uint32_t  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_err(uint32_t e) {
12858         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
12859         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
12860         *ret_conv = CResult_StringErrorZ_err(e_conv);
12861         return (uint64_t)ret_conv;
12862 }
12863
12864 jboolean  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
12865         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
12866         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
12867         return ret_val;
12868 }
12869
12870 void  __attribute__((visibility("default"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
12871         if ((_res & 1) != 0) return;
12872         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12873         CHECK_ACCESS(_res_ptr);
12874         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
12875         FREE((void*)_res);
12876         CResult_StringErrorZ_free(_res_conv);
12877 }
12878
12879 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
12880         LDKChannelMonitorUpdate o_conv;
12881         o_conv.inner = (void*)(o & (~1));
12882         o_conv.is_owned = (o & 1) || (o == 0);
12883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12884         o_conv = ChannelMonitorUpdate_clone(&o_conv);
12885         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12886         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
12887         return (uint64_t)ret_conv;
12888 }
12889
12890 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
12891         LDKDecodeError e_conv;
12892         e_conv.inner = (void*)(e & (~1));
12893         e_conv.is_owned = (e & 1) || (e == 0);
12894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12895         e_conv = DecodeError_clone(&e_conv);
12896         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12897         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
12898         return (uint64_t)ret_conv;
12899 }
12900
12901 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
12902         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
12903         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
12904         return ret_val;
12905 }
12906
12907 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
12908         if ((_res & 1) != 0) return;
12909         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12910         CHECK_ACCESS(_res_ptr);
12911         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
12912         FREE((void*)_res);
12913         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
12914 }
12915
12916 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
12917         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12918         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
12919         return (uint64_t)ret_conv;
12920 }
12921 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
12922         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
12923         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
12924         return ret_val;
12925 }
12926
12927 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
12928         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
12929         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
12930         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
12931         return (uint64_t)ret_conv;
12932 }
12933
12934 uint32_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_some(uint32_t o) {
12935         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12936         CHECK_ACCESS(o_ptr);
12937         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
12938         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)o) & ~1));
12939         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12940         *ret_copy = COption_MonitorEventZ_some(o_conv);
12941         uint64_t ret_ref = (uint64_t)ret_copy;
12942         return ret_ref;
12943 }
12944
12945 uint32_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_none() {
12946         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12947         *ret_copy = COption_MonitorEventZ_none();
12948         uint64_t ret_ref = (uint64_t)ret_copy;
12949         return ret_ref;
12950 }
12951
12952 void  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
12953         if ((_res & 1) != 0) return;
12954         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12955         CHECK_ACCESS(_res_ptr);
12956         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
12957         FREE((void*)_res);
12958         COption_MonitorEventZ_free(_res_conv);
12959 }
12960
12961 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
12962         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12963         *ret_copy = COption_MonitorEventZ_clone(arg);
12964 uint64_t ret_ref = (uint64_t)ret_copy;
12965         return ret_ref;
12966 }
12967 int64_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
12968         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
12969         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
12970         return ret_val;
12971 }
12972
12973 uint32_t  __attribute__((visibility("default"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
12974         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
12975         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
12976         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
12977         uint64_t ret_ref = (uint64_t)ret_copy;
12978         return ret_ref;
12979 }
12980
12981 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
12982         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12983         CHECK_ACCESS(o_ptr);
12984         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
12985         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uint64_t)o) & ~1));
12986         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
12987         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
12988         return (uint64_t)ret_conv;
12989 }
12990
12991 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
12992         LDKDecodeError e_conv;
12993         e_conv.inner = (void*)(e & (~1));
12994         e_conv.is_owned = (e & 1) || (e == 0);
12995         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12996         e_conv = DecodeError_clone(&e_conv);
12997         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
12998         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
12999         return (uint64_t)ret_conv;
13000 }
13001
13002 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
13003         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
13004         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
13005         return ret_val;
13006 }
13007
13008 void  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
13009         if ((_res & 1) != 0) return;
13010         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13011         CHECK_ACCESS(_res_ptr);
13012         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
13013         FREE((void*)_res);
13014         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
13015 }
13016
13017 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
13018         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
13019         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
13020         return (uint64_t)ret_conv;
13021 }
13022 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
13023         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
13024         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
13025         return ret_val;
13026 }
13027
13028 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
13029         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
13030         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
13031         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
13032         return (uint64_t)ret_conv;
13033 }
13034
13035 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
13036         LDKHTLCUpdate o_conv;
13037         o_conv.inner = (void*)(o & (~1));
13038         o_conv.is_owned = (o & 1) || (o == 0);
13039         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13040         o_conv = HTLCUpdate_clone(&o_conv);
13041         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13042         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
13043         return (uint64_t)ret_conv;
13044 }
13045
13046 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
13047         LDKDecodeError e_conv;
13048         e_conv.inner = (void*)(e & (~1));
13049         e_conv.is_owned = (e & 1) || (e == 0);
13050         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13051         e_conv = DecodeError_clone(&e_conv);
13052         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13053         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
13054         return (uint64_t)ret_conv;
13055 }
13056
13057 jboolean  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
13058         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
13059         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
13060         return ret_val;
13061 }
13062
13063 void  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
13064         if ((_res & 1) != 0) return;
13065         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13066         CHECK_ACCESS(_res_ptr);
13067         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
13068         FREE((void*)_res);
13069         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
13070 }
13071
13072 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
13073         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13074         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
13075         return (uint64_t)ret_conv;
13076 }
13077 int64_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
13078         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
13079         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
13080         return ret_val;
13081 }
13082
13083 uint32_t  __attribute__((visibility("default"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
13084         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
13085         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
13086         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
13087         return (uint64_t)ret_conv;
13088 }
13089
13090 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
13091         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13092         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
13093         return ((uint64_t)ret_conv);
13094 }
13095 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
13096         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
13097         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
13098         return ret_val;
13099 }
13100
13101 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
13102         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
13103         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13104         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
13105         return ((uint64_t)ret_conv);
13106 }
13107
13108 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
13109         LDKOutPoint a_conv;
13110         a_conv.inner = (void*)(a & (~1));
13111         a_conv.is_owned = (a & 1) || (a == 0);
13112         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13113         a_conv = OutPoint_clone(&a_conv);
13114         LDKCVec_u8Z b_ref;
13115         b_ref.datalen = *((uint32_t*)b);
13116         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
13117         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
13118         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
13119         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
13120         return ((uint64_t)ret_conv);
13121 }
13122
13123 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
13124         if ((_res & 1) != 0) return;
13125         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13126         CHECK_ACCESS(_res_ptr);
13127         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
13128         FREE((void*)_res);
13129         C2Tuple_OutPointScriptZ_free(_res_conv);
13130 }
13131
13132 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
13133         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13134         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
13135         return ((uint64_t)ret_conv);
13136 }
13137 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
13138         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
13139         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
13140         return ret_val;
13141 }
13142
13143 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
13144         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
13145         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13146         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
13147         return ((uint64_t)ret_conv);
13148 }
13149
13150 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
13151         LDKCVec_u8Z b_ref;
13152         b_ref.datalen = *((uint32_t*)b);
13153         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
13154         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
13155         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
13156         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
13157         return ((uint64_t)ret_conv);
13158 }
13159
13160 void  __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
13161         if ((_res & 1) != 0) return;
13162         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13163         CHECK_ACCESS(_res_ptr);
13164         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
13165         FREE((void*)_res);
13166         C2Tuple_u32ScriptZ_free(_res_conv);
13167 }
13168
13169 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
13170         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
13171         _res_constr.datalen = *((uint32_t*)_res);
13172         if (_res_constr.datalen > 0)
13173                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
13174         else
13175                 _res_constr.data = NULL;
13176         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13177         for (size_t v = 0; v < _res_constr.datalen; v++) {
13178                 uint32_t _res_conv_21 = _res_vals[v];
13179                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
13180                 CHECK_ACCESS(_res_conv_21_ptr);
13181                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
13182                 FREE((void*)_res_conv_21);
13183                 _res_constr.data[v] = _res_conv_21_conv;
13184         }
13185         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
13186 }
13187
13188 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
13189         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13190         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
13191         return ((uint64_t)ret_conv);
13192 }
13193 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
13194         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
13195         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
13196         return ret_val;
13197 }
13198
13199 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
13200         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
13201         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13202         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
13203         return ((uint64_t)ret_conv);
13204 }
13205
13206 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
13207         LDKThirtyTwoBytes a_ref;
13208         CHECK(*((uint32_t*)a) == 32);
13209         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
13210         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
13211         b_constr.datalen = *((uint32_t*)b);
13212         if (b_constr.datalen > 0)
13213                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
13214         else
13215                 b_constr.data = NULL;
13216         uint32_t* b_vals = (uint32_t*)(b + 4);
13217         for (size_t v = 0; v < b_constr.datalen; v++) {
13218                 uint32_t b_conv_21 = b_vals[v];
13219                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
13220                 CHECK_ACCESS(b_conv_21_ptr);
13221                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
13222                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
13223                 b_constr.data[v] = b_conv_21_conv;
13224         }
13225         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
13226         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
13227         return ((uint64_t)ret_conv);
13228 }
13229
13230 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
13231         if ((_res & 1) != 0) return;
13232         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13233         CHECK_ACCESS(_res_ptr);
13234         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
13235         FREE((void*)_res);
13236         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
13237 }
13238
13239 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
13240         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
13241         _res_constr.datalen = *((uint32_t*)_res);
13242         if (_res_constr.datalen > 0)
13243                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
13244         else
13245                 _res_constr.data = NULL;
13246         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13247         for (size_t o = 0; o < _res_constr.datalen; o++) {
13248                 uint32_t _res_conv_40 = _res_vals[o];
13249                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
13250                 CHECK_ACCESS(_res_conv_40_ptr);
13251                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
13252                 FREE((void*)_res_conv_40);
13253                 _res_constr.data[o] = _res_conv_40_conv;
13254         }
13255         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
13256 }
13257
13258 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
13259         LDKCVec_EventZ _res_constr;
13260         _res_constr.datalen = *((uint32_t*)_res);
13261         if (_res_constr.datalen > 0)
13262                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
13263         else
13264                 _res_constr.data = NULL;
13265         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13266         for (size_t h = 0; h < _res_constr.datalen; h++) {
13267                 uint32_t _res_conv_7 = _res_vals[h];
13268                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
13269                 CHECK_ACCESS(_res_conv_7_ptr);
13270                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
13271                 FREE((void*)_res_conv_7);
13272                 _res_constr.data[h] = _res_conv_7_conv;
13273         }
13274         CVec_EventZ_free(_res_constr);
13275 }
13276
13277 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
13278         LDKCVec_TransactionZ _res_constr;
13279         _res_constr.datalen = *((uint32_t*)_res);
13280         if (_res_constr.datalen > 0)
13281                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
13282         else
13283                 _res_constr.data = NULL;
13284         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
13285         for (size_t m = 0; m < _res_constr.datalen; m++) {
13286                 int8_tArray _res_conv_12 = _res_vals[m];
13287                 LDKTransaction _res_conv_12_ref;
13288                 _res_conv_12_ref.datalen = *((uint32_t*)_res_conv_12);
13289                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
13290                 memcpy(_res_conv_12_ref.data, (uint8_t*)(_res_conv_12 + 4), _res_conv_12_ref.datalen);
13291                 _res_conv_12_ref.data_is_owned = true;
13292                 _res_constr.data[m] = _res_conv_12_ref;
13293         }
13294         CVec_TransactionZ_free(_res_constr);
13295 }
13296
13297 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
13298         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13299         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
13300         return ((uint64_t)ret_conv);
13301 }
13302 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
13303         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
13304         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
13305         return ret_val;
13306 }
13307
13308 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
13309         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
13310         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13311         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
13312         return ((uint64_t)ret_conv);
13313 }
13314
13315 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
13316         void* b_ptr = (void*)(((uint64_t)b) & ~1);
13317         CHECK_ACCESS(b_ptr);
13318         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
13319         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
13320         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
13321         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
13322         return ((uint64_t)ret_conv);
13323 }
13324
13325 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
13326         if ((_res & 1) != 0) return;
13327         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13328         CHECK_ACCESS(_res_ptr);
13329         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
13330         FREE((void*)_res);
13331         C2Tuple_u32TxOutZ_free(_res_conv);
13332 }
13333
13334 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
13335         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
13336         _res_constr.datalen = *((uint32_t*)_res);
13337         if (_res_constr.datalen > 0)
13338                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
13339         else
13340                 _res_constr.data = NULL;
13341         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13342         for (size_t u = 0; u < _res_constr.datalen; u++) {
13343                 uint32_t _res_conv_20 = _res_vals[u];
13344                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
13345                 CHECK_ACCESS(_res_conv_20_ptr);
13346                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
13347                 FREE((void*)_res_conv_20);
13348                 _res_constr.data[u] = _res_conv_20_conv;
13349         }
13350         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
13351 }
13352
13353 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
13354         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13355         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
13356         return ((uint64_t)ret_conv);
13357 }
13358 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
13359         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
13360         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
13361         return ret_val;
13362 }
13363
13364 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
13365         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
13366         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13367         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
13368         return ((uint64_t)ret_conv);
13369 }
13370
13371 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
13372         LDKThirtyTwoBytes a_ref;
13373         CHECK(*((uint32_t*)a) == 32);
13374         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
13375         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
13376         b_constr.datalen = *((uint32_t*)b);
13377         if (b_constr.datalen > 0)
13378                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
13379         else
13380                 b_constr.data = NULL;
13381         uint32_t* b_vals = (uint32_t*)(b + 4);
13382         for (size_t u = 0; u < b_constr.datalen; u++) {
13383                 uint32_t b_conv_20 = b_vals[u];
13384                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
13385                 CHECK_ACCESS(b_conv_20_ptr);
13386                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
13387                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
13388                 b_constr.data[u] = b_conv_20_conv;
13389         }
13390         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
13391         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
13392         return ((uint64_t)ret_conv);
13393 }
13394
13395 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
13396         if ((_res & 1) != 0) return;
13397         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13398         CHECK_ACCESS(_res_ptr);
13399         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
13400         FREE((void*)_res);
13401         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
13402 }
13403
13404 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
13405         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
13406         _res_constr.datalen = *((uint32_t*)_res);
13407         if (_res_constr.datalen > 0)
13408                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
13409         else
13410                 _res_constr.data = NULL;
13411         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13412         for (size_t n = 0; n < _res_constr.datalen; n++) {
13413                 uint32_t _res_conv_39 = _res_vals[n];
13414                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
13415                 CHECK_ACCESS(_res_conv_39_ptr);
13416                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
13417                 FREE((void*)_res_conv_39);
13418                 _res_constr.data[n] = _res_conv_39_conv;
13419         }
13420         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
13421 }
13422
13423 void  __attribute__((visibility("default"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
13424         LDKCVec_BalanceZ _res_constr;
13425         _res_constr.datalen = *((uint32_t*)_res);
13426         if (_res_constr.datalen > 0)
13427                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
13428         else
13429                 _res_constr.data = NULL;
13430         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13431         for (size_t j = 0; j < _res_constr.datalen; j++) {
13432                 uint32_t _res_conv_9 = _res_vals[j];
13433                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
13434                 CHECK_ACCESS(_res_conv_9_ptr);
13435                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
13436                 FREE((void*)_res_conv_9);
13437                 _res_constr.data[j] = _res_conv_9_conv;
13438         }
13439         CVec_BalanceZ_free(_res_constr);
13440 }
13441
13442 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
13443         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13444         CHECK_ACCESS(o_ptr);
13445         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
13446         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
13447         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13448         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
13449         return (uint64_t)ret_conv;
13450 }
13451
13452 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
13453         LDKDecodeError e_conv;
13454         e_conv.inner = (void*)(e & (~1));
13455         e_conv.is_owned = (e & 1) || (e == 0);
13456         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13457         e_conv = DecodeError_clone(&e_conv);
13458         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13459         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
13460         return (uint64_t)ret_conv;
13461 }
13462
13463 jboolean  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
13464         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
13465         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
13466         return ret_val;
13467 }
13468
13469 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
13470         if ((_res & 1) != 0) return;
13471         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13472         CHECK_ACCESS(_res_ptr);
13473         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
13474         FREE((void*)_res);
13475         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
13476 }
13477
13478 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
13479         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13480         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
13481         return (uint64_t)ret_conv;
13482 }
13483 int64_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
13484         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
13485         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
13486         return ret_val;
13487 }
13488
13489 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
13490         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
13491         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
13492         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
13493         return (uint64_t)ret_conv;
13494 }
13495
13496 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
13497         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13498         *ret_conv = CResult_NoneLightningErrorZ_ok();
13499         return (uint64_t)ret_conv;
13500 }
13501
13502 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
13503         LDKLightningError e_conv;
13504         e_conv.inner = (void*)(e & (~1));
13505         e_conv.is_owned = (e & 1) || (e == 0);
13506         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13507         e_conv = LightningError_clone(&e_conv);
13508         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13509         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
13510         return (uint64_t)ret_conv;
13511 }
13512
13513 jboolean  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
13514         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
13515         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
13516         return ret_val;
13517 }
13518
13519 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
13520         if ((_res & 1) != 0) return;
13521         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13522         CHECK_ACCESS(_res_ptr);
13523         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
13524         FREE((void*)_res);
13525         CResult_NoneLightningErrorZ_free(_res_conv);
13526 }
13527
13528 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
13529         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13530         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
13531         return (uint64_t)ret_conv;
13532 }
13533 int64_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
13534         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
13535         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
13536         return ret_val;
13537 }
13538
13539 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
13540         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
13541         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13542         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
13543         return (uint64_t)ret_conv;
13544 }
13545
13546 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
13547         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13548         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
13549         return ((uint64_t)ret_conv);
13550 }
13551 int64_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
13552         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
13553         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
13554         return ret_val;
13555 }
13556
13557 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
13558         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
13559         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13560         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
13561         return ((uint64_t)ret_conv);
13562 }
13563
13564 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
13565         LDKPublicKey a_ref;
13566         CHECK(*((uint32_t*)a) == 33);
13567         memcpy(a_ref.compressed_form, (uint8_t*)(a + 4), 33);
13568         void* b_ptr = (void*)(((uint64_t)b) & ~1);
13569         CHECK_ACCESS(b_ptr);
13570         LDKType b_conv = *(LDKType*)(b_ptr);
13571         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13572         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
13573         return ((uint64_t)ret_conv);
13574 }
13575
13576 void  __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
13577         if ((_res & 1) != 0) return;
13578         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13579         CHECK_ACCESS(_res_ptr);
13580         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
13581         FREE((void*)_res);
13582         C2Tuple_PublicKeyTypeZ_free(_res_conv);
13583 }
13584
13585 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
13586         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
13587         _res_constr.datalen = *((uint32_t*)_res);
13588         if (_res_constr.datalen > 0)
13589                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13590         else
13591                 _res_constr.data = NULL;
13592         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13593         for (size_t z = 0; z < _res_constr.datalen; z++) {
13594                 uint32_t _res_conv_25 = _res_vals[z];
13595                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
13596                 CHECK_ACCESS(_res_conv_25_ptr);
13597                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
13598                 FREE((void*)_res_conv_25);
13599                 _res_constr.data[z] = _res_conv_25_conv;
13600         }
13601         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
13602 }
13603
13604 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
13605         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13606         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13607         return (uint64_t)ret_conv;
13608 }
13609
13610 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
13611         LDKLightningError e_conv;
13612         e_conv.inner = (void*)(e & (~1));
13613         e_conv.is_owned = (e & 1) || (e == 0);
13614         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13615         e_conv = LightningError_clone(&e_conv);
13616         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13617         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13618         return (uint64_t)ret_conv;
13619 }
13620
13621 jboolean  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
13622         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
13623         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
13624         return ret_val;
13625 }
13626
13627 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
13628         if ((_res & 1) != 0) return;
13629         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13630         CHECK_ACCESS(_res_ptr);
13631         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
13632         FREE((void*)_res);
13633         CResult_boolLightningErrorZ_free(_res_conv);
13634 }
13635
13636 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
13637         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13638         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
13639         return (uint64_t)ret_conv;
13640 }
13641 int64_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
13642         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
13643         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
13644         return ret_val;
13645 }
13646
13647 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
13648         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13649         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13650         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13651         return (uint64_t)ret_conv;
13652 }
13653
13654 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
13655         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13656         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
13657         return ((uint64_t)ret_conv);
13658 }
13659 int64_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
13660         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
13661         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
13662         return ret_val;
13663 }
13664
13665 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
13666         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13667         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13668         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13669         return ((uint64_t)ret_conv);
13670 }
13671
13672 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
13673         LDKChannelAnnouncement a_conv;
13674         a_conv.inner = (void*)(a & (~1));
13675         a_conv.is_owned = (a & 1) || (a == 0);
13676         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13677         a_conv = ChannelAnnouncement_clone(&a_conv);
13678         LDKChannelUpdate b_conv;
13679         b_conv.inner = (void*)(b & (~1));
13680         b_conv.is_owned = (b & 1) || (b == 0);
13681         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13682         b_conv = ChannelUpdate_clone(&b_conv);
13683         LDKChannelUpdate c_conv;
13684         c_conv.inner = (void*)(c & (~1));
13685         c_conv.is_owned = (c & 1) || (c == 0);
13686         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
13687         c_conv = ChannelUpdate_clone(&c_conv);
13688         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13689         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13690         return ((uint64_t)ret_conv);
13691 }
13692
13693 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
13694         if ((_res & 1) != 0) return;
13695         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13696         CHECK_ACCESS(_res_ptr);
13697         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
13698         FREE((void*)_res);
13699         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
13700 }
13701
13702 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
13703         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
13704         _res_constr.datalen = *((uint32_t*)_res);
13705         if (_res_constr.datalen > 0)
13706                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13707         else
13708                 _res_constr.data = NULL;
13709         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13710         for (size_t h = 0; h < _res_constr.datalen; h++) {
13711                 uint32_t _res_conv_59 = _res_vals[h];
13712                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
13713                 CHECK_ACCESS(_res_conv_59_ptr);
13714                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
13715                 FREE((void*)_res_conv_59);
13716                 _res_constr.data[h] = _res_conv_59_conv;
13717         }
13718         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
13719 }
13720
13721 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
13722         LDKCVec_NodeAnnouncementZ _res_constr;
13723         _res_constr.datalen = *((uint32_t*)_res);
13724         if (_res_constr.datalen > 0)
13725                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13726         else
13727                 _res_constr.data = NULL;
13728         uint32_t* _res_vals = (uint32_t*)(_res + 4);
13729         for (size_t s = 0; s < _res_constr.datalen; s++) {
13730                 uint32_t _res_conv_18 = _res_vals[s];
13731                 LDKNodeAnnouncement _res_conv_18_conv;
13732                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
13733                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
13734                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
13735                 _res_constr.data[s] = _res_conv_18_conv;
13736         }
13737         CVec_NodeAnnouncementZ_free(_res_constr);
13738 }
13739
13740 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
13741         LDKCVec_PublicKeyZ _res_constr;
13742         _res_constr.datalen = *((uint32_t*)_res);
13743         if (_res_constr.datalen > 0)
13744                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
13745         else
13746                 _res_constr.data = NULL;
13747         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
13748         for (size_t m = 0; m < _res_constr.datalen; m++) {
13749                 int8_tArray _res_conv_12 = _res_vals[m];
13750                 LDKPublicKey _res_conv_12_ref;
13751                 CHECK(*((uint32_t*)_res_conv_12) == 33);
13752                 memcpy(_res_conv_12_ref.compressed_form, (uint8_t*)(_res_conv_12 + 4), 33);
13753                 _res_constr.data[m] = _res_conv_12_ref;
13754         }
13755         CVec_PublicKeyZ_free(_res_constr);
13756 }
13757
13758 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
13759         LDKCVec_u8Z o_ref;
13760         o_ref.datalen = *((uint32_t*)o);
13761         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
13762         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
13763         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13764         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
13765         return (uint64_t)ret_conv;
13766 }
13767
13768 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
13769         LDKPeerHandleError e_conv;
13770         e_conv.inner = (void*)(e & (~1));
13771         e_conv.is_owned = (e & 1) || (e == 0);
13772         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13773         e_conv = PeerHandleError_clone(&e_conv);
13774         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13775         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
13776         return (uint64_t)ret_conv;
13777 }
13778
13779 jboolean  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
13780         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
13781         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
13782         return ret_val;
13783 }
13784
13785 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
13786         if ((_res & 1) != 0) return;
13787         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13788         CHECK_ACCESS(_res_ptr);
13789         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
13790         FREE((void*)_res);
13791         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
13792 }
13793
13794 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
13795         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13796         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
13797         return (uint64_t)ret_conv;
13798 }
13799 int64_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
13800         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
13801         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
13802         return ret_val;
13803 }
13804
13805 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
13806         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
13807         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
13808         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
13809         return (uint64_t)ret_conv;
13810 }
13811
13812 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
13813         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13814         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
13815         return (uint64_t)ret_conv;
13816 }
13817
13818 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
13819         LDKPeerHandleError e_conv;
13820         e_conv.inner = (void*)(e & (~1));
13821         e_conv.is_owned = (e & 1) || (e == 0);
13822         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13823         e_conv = PeerHandleError_clone(&e_conv);
13824         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13825         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
13826         return (uint64_t)ret_conv;
13827 }
13828
13829 jboolean  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
13830         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
13831         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
13832         return ret_val;
13833 }
13834
13835 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
13836         if ((_res & 1) != 0) return;
13837         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13838         CHECK_ACCESS(_res_ptr);
13839         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
13840         FREE((void*)_res);
13841         CResult_NonePeerHandleErrorZ_free(_res_conv);
13842 }
13843
13844 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
13845         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13846         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
13847         return (uint64_t)ret_conv;
13848 }
13849 int64_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
13850         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
13851         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
13852         return ret_val;
13853 }
13854
13855 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
13856         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
13857         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
13858         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
13859         return (uint64_t)ret_conv;
13860 }
13861
13862 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
13863         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13864         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
13865         return (uint64_t)ret_conv;
13866 }
13867
13868 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
13869         LDKPeerHandleError e_conv;
13870         e_conv.inner = (void*)(e & (~1));
13871         e_conv.is_owned = (e & 1) || (e == 0);
13872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13873         e_conv = PeerHandleError_clone(&e_conv);
13874         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13875         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
13876         return (uint64_t)ret_conv;
13877 }
13878
13879 jboolean  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
13880         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
13881         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
13882         return ret_val;
13883 }
13884
13885 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
13886         if ((_res & 1) != 0) return;
13887         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13888         CHECK_ACCESS(_res_ptr);
13889         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
13890         FREE((void*)_res);
13891         CResult_boolPeerHandleErrorZ_free(_res_conv);
13892 }
13893
13894 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
13895         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13896         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
13897         return (uint64_t)ret_conv;
13898 }
13899 int64_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
13900         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
13901         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
13902         return ret_val;
13903 }
13904
13905 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
13906         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
13907         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
13908         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
13909         return (uint64_t)ret_conv;
13910 }
13911
13912 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
13913         LDKNodeId o_conv;
13914         o_conv.inner = (void*)(o & (~1));
13915         o_conv.is_owned = (o & 1) || (o == 0);
13916         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13917         o_conv = NodeId_clone(&o_conv);
13918         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13919         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
13920         return (uint64_t)ret_conv;
13921 }
13922
13923 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
13924         LDKDecodeError e_conv;
13925         e_conv.inner = (void*)(e & (~1));
13926         e_conv.is_owned = (e & 1) || (e == 0);
13927         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13928         e_conv = DecodeError_clone(&e_conv);
13929         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13930         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
13931         return (uint64_t)ret_conv;
13932 }
13933
13934 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
13935         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
13936         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
13937         return ret_val;
13938 }
13939
13940 void  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
13941         if ((_res & 1) != 0) return;
13942         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13943         CHECK_ACCESS(_res_ptr);
13944         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
13945         FREE((void*)_res);
13946         CResult_NodeIdDecodeErrorZ_free(_res_conv);
13947 }
13948
13949 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
13950         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13951         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
13952         return (uint64_t)ret_conv;
13953 }
13954 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
13955         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
13956         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
13957         return ret_val;
13958 }
13959
13960 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
13961         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
13962         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13963         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
13964         return (uint64_t)ret_conv;
13965 }
13966
13967 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
13968         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13969         CHECK_ACCESS(o_ptr);
13970         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
13971         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)o) & ~1));
13972         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13973         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
13974         return (uint64_t)ret_conv;
13975 }
13976
13977 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
13978         LDKDecodeError e_conv;
13979         e_conv.inner = (void*)(e & (~1));
13980         e_conv.is_owned = (e & 1) || (e == 0);
13981         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13982         e_conv = DecodeError_clone(&e_conv);
13983         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13984         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
13985         return (uint64_t)ret_conv;
13986 }
13987
13988 jboolean  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
13989         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
13990         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
13991         return ret_val;
13992 }
13993
13994 void  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
13995         if ((_res & 1) != 0) return;
13996         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13997         CHECK_ACCESS(_res_ptr);
13998         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
13999         FREE((void*)_res);
14000         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
14001 }
14002
14003 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
14004         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14005         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
14006         return (uint64_t)ret_conv;
14007 }
14008 int64_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
14009         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
14010         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
14011         return ret_val;
14012 }
14013
14014 uint32_t  __attribute__((visibility("default"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
14015         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
14016         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
14017         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
14018         return (uint64_t)ret_conv;
14019 }
14020
14021 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_some(uint32_t o) {
14022         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14023         CHECK_ACCESS(o_ptr);
14024         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
14025         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14026         *ret_copy = COption_AccessZ_some(o_conv);
14027         uint64_t ret_ref = (uint64_t)ret_copy;
14028         return ret_ref;
14029 }
14030
14031 uint32_t  __attribute__((visibility("default"))) TS_COption_AccessZ_none() {
14032         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
14033         *ret_copy = COption_AccessZ_none();
14034         uint64_t ret_ref = (uint64_t)ret_copy;
14035         return ret_ref;
14036 }
14037
14038 void  __attribute__((visibility("default"))) TS_COption_AccessZ_free(uint32_t _res) {
14039         if ((_res & 1) != 0) return;
14040         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14041         CHECK_ACCESS(_res_ptr);
14042         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
14043         FREE((void*)_res);
14044         COption_AccessZ_free(_res_conv);
14045 }
14046
14047 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
14048         LDKDirectionalChannelInfo o_conv;
14049         o_conv.inner = (void*)(o & (~1));
14050         o_conv.is_owned = (o & 1) || (o == 0);
14051         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14052         o_conv = DirectionalChannelInfo_clone(&o_conv);
14053         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14054         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
14055         return (uint64_t)ret_conv;
14056 }
14057
14058 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
14059         LDKDecodeError e_conv;
14060         e_conv.inner = (void*)(e & (~1));
14061         e_conv.is_owned = (e & 1) || (e == 0);
14062         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14063         e_conv = DecodeError_clone(&e_conv);
14064         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14065         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
14066         return (uint64_t)ret_conv;
14067 }
14068
14069 jboolean  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14070         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
14071         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
14072         return ret_val;
14073 }
14074
14075 void  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
14076         if ((_res & 1) != 0) return;
14077         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14078         CHECK_ACCESS(_res_ptr);
14079         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
14080         FREE((void*)_res);
14081         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
14082 }
14083
14084 static inline uint64_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14085         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14086         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
14087         return (uint64_t)ret_conv;
14088 }
14089 int64_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14090         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
14091         int64_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14092         return ret_val;
14093 }
14094
14095 uint32_t  __attribute__((visibility("default"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14096         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
14097         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
14098         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
14099         return (uint64_t)ret_conv;
14100 }
14101
14102 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
14103         LDKChannelInfo o_conv;
14104         o_conv.inner = (void*)(o & (~1));
14105         o_conv.is_owned = (o & 1) || (o == 0);
14106         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14107         o_conv = ChannelInfo_clone(&o_conv);
14108         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14109         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
14110         return (uint64_t)ret_conv;
14111 }
14112
14113 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
14114         LDKDecodeError e_conv;
14115         e_conv.inner = (void*)(e & (~1));
14116         e_conv.is_owned = (e & 1) || (e == 0);
14117         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14118         e_conv = DecodeError_clone(&e_conv);
14119         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14120         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
14121         return (uint64_t)ret_conv;
14122 }
14123
14124 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
14125         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
14126         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
14127         return ret_val;
14128 }
14129
14130 void  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
14131         if ((_res & 1) != 0) return;
14132         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14133         CHECK_ACCESS(_res_ptr);
14134         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
14135         FREE((void*)_res);
14136         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
14137 }
14138
14139 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
14140         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14141         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
14142         return (uint64_t)ret_conv;
14143 }
14144 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14145         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
14146         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
14147         return ret_val;
14148 }
14149
14150 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
14151         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
14152         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
14153         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
14154         return (uint64_t)ret_conv;
14155 }
14156
14157 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
14158         LDKRoutingFees o_conv;
14159         o_conv.inner = (void*)(o & (~1));
14160         o_conv.is_owned = (o & 1) || (o == 0);
14161         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14162         o_conv = RoutingFees_clone(&o_conv);
14163         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14164         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
14165         return (uint64_t)ret_conv;
14166 }
14167
14168 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
14169         LDKDecodeError e_conv;
14170         e_conv.inner = (void*)(e & (~1));
14171         e_conv.is_owned = (e & 1) || (e == 0);
14172         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14173         e_conv = DecodeError_clone(&e_conv);
14174         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14175         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
14176         return (uint64_t)ret_conv;
14177 }
14178
14179 jboolean  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14180         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14181         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14182         return ret_val;
14183 }
14184
14185 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14186         if ((_res & 1) != 0) return;
14187         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14188         CHECK_ACCESS(_res_ptr);
14189         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14190         FREE((void*)_res);
14191         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14192 }
14193
14194 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14195         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14196         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14197         return (uint64_t)ret_conv;
14198 }
14199 int64_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14200         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14201         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14202         return ret_val;
14203 }
14204
14205 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14206         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14207         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14208         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14209         return (uint64_t)ret_conv;
14210 }
14211
14212 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14213         LDKNodeAnnouncementInfo o_conv;
14214         o_conv.inner = (void*)(o & (~1));
14215         o_conv.is_owned = (o & 1) || (o == 0);
14216         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14217         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14218         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14219         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14220         return (uint64_t)ret_conv;
14221 }
14222
14223 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14224         LDKDecodeError e_conv;
14225         e_conv.inner = (void*)(e & (~1));
14226         e_conv.is_owned = (e & 1) || (e == 0);
14227         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14228         e_conv = DecodeError_clone(&e_conv);
14229         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14230         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14231         return (uint64_t)ret_conv;
14232 }
14233
14234 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14235         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14236         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14237         return ret_val;
14238 }
14239
14240 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14241         if ((_res & 1) != 0) return;
14242         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14243         CHECK_ACCESS(_res_ptr);
14244         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14245         FREE((void*)_res);
14246         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14247 }
14248
14249 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14250         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14251         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14252         return (uint64_t)ret_conv;
14253 }
14254 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14255         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14256         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14257         return ret_val;
14258 }
14259
14260 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14261         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14262         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14263         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14264         return (uint64_t)ret_conv;
14265 }
14266
14267 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
14268         LDKCVec_u64Z _res_constr;
14269         _res_constr.datalen = *((uint32_t*)_res);
14270         if (_res_constr.datalen > 0)
14271                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14272         else
14273                 _res_constr.data = NULL;
14274         int64_t* _res_vals = (int64_t*)(_res + 4);
14275         for (size_t i = 0; i < _res_constr.datalen; i++) {
14276                 int64_t _res_conv_8 = _res_vals[i];
14277                 _res_constr.data[i] = _res_conv_8;
14278         }
14279         CVec_u64Z_free(_res_constr);
14280 }
14281
14282 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14283         LDKNodeInfo o_conv;
14284         o_conv.inner = (void*)(o & (~1));
14285         o_conv.is_owned = (o & 1) || (o == 0);
14286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14287         o_conv = NodeInfo_clone(&o_conv);
14288         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14289         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14290         return (uint64_t)ret_conv;
14291 }
14292
14293 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14294         LDKDecodeError e_conv;
14295         e_conv.inner = (void*)(e & (~1));
14296         e_conv.is_owned = (e & 1) || (e == 0);
14297         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14298         e_conv = DecodeError_clone(&e_conv);
14299         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14300         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14301         return (uint64_t)ret_conv;
14302 }
14303
14304 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14305         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14306         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14307         return ret_val;
14308 }
14309
14310 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14311         if ((_res & 1) != 0) return;
14312         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14313         CHECK_ACCESS(_res_ptr);
14314         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14315         FREE((void*)_res);
14316         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14317 }
14318
14319 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14320         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14321         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14322         return (uint64_t)ret_conv;
14323 }
14324 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14325         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14326         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14327         return ret_val;
14328 }
14329
14330 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14331         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14332         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14333         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14334         return (uint64_t)ret_conv;
14335 }
14336
14337 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14338         LDKNetworkGraph o_conv;
14339         o_conv.inner = (void*)(o & (~1));
14340         o_conv.is_owned = (o & 1) || (o == 0);
14341         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14342         o_conv = NetworkGraph_clone(&o_conv);
14343         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14344         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14345         return (uint64_t)ret_conv;
14346 }
14347
14348 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14349         LDKDecodeError e_conv;
14350         e_conv.inner = (void*)(e & (~1));
14351         e_conv.is_owned = (e & 1) || (e == 0);
14352         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14353         e_conv = DecodeError_clone(&e_conv);
14354         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14355         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14356         return (uint64_t)ret_conv;
14357 }
14358
14359 jboolean  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14360         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14361         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14362         return ret_val;
14363 }
14364
14365 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14366         if ((_res & 1) != 0) return;
14367         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14368         CHECK_ACCESS(_res_ptr);
14369         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14370         FREE((void*)_res);
14371         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14372 }
14373
14374 static inline uint64_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
14375         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14376         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
14377         return (uint64_t)ret_conv;
14378 }
14379 int64_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
14380         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
14381         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
14382         return ret_val;
14383 }
14384
14385 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
14386         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
14387         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14388         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
14389         return (uint64_t)ret_conv;
14390 }
14391
14392 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14393         LDKCVec_NetAddressZ o_constr;
14394         o_constr.datalen = *((uint32_t*)o);
14395         if (o_constr.datalen > 0)
14396                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14397         else
14398                 o_constr.data = NULL;
14399         uint32_t* o_vals = (uint32_t*)(o + 4);
14400         for (size_t m = 0; m < o_constr.datalen; m++) {
14401                 uint32_t o_conv_12 = o_vals[m];
14402                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
14403                 CHECK_ACCESS(o_conv_12_ptr);
14404                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14405                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
14406                 o_constr.data[m] = o_conv_12_conv;
14407         }
14408         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14409         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14410         uint64_t ret_ref = (uint64_t)ret_copy;
14411         return ret_ref;
14412 }
14413
14414 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_none() {
14415         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14416         *ret_copy = COption_CVec_NetAddressZZ_none();
14417         uint64_t ret_ref = (uint64_t)ret_copy;
14418         return ret_ref;
14419 }
14420
14421 void  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14422         if ((_res & 1) != 0) return;
14423         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14424         CHECK_ACCESS(_res_ptr);
14425         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14426         FREE((void*)_res);
14427         COption_CVec_NetAddressZZ_free(_res_conv);
14428 }
14429
14430 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14431         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14432         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14433 uint64_t ret_ref = (uint64_t)ret_copy;
14434         return ret_ref;
14435 }
14436 int64_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14437         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14438         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14439         return ret_val;
14440 }
14441
14442 uint32_t  __attribute__((visibility("default"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14443         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14444         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14445         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14446         uint64_t ret_ref = (uint64_t)ret_copy;
14447         return ret_ref;
14448 }
14449
14450 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
14451         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14452         CHECK_ACCESS(o_ptr);
14453         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
14454         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
14455         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14456         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
14457         return (uint64_t)ret_conv;
14458 }
14459
14460 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
14461         LDKDecodeError e_conv;
14462         e_conv.inner = (void*)(e & (~1));
14463         e_conv.is_owned = (e & 1) || (e == 0);
14464         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14465         e_conv = DecodeError_clone(&e_conv);
14466         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14467         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
14468         return (uint64_t)ret_conv;
14469 }
14470
14471 jboolean  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
14472         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
14473         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
14474         return ret_val;
14475 }
14476
14477 void  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
14478         if ((_res & 1) != 0) return;
14479         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14480         CHECK_ACCESS(_res_ptr);
14481         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
14482         FREE((void*)_res);
14483         CResult_NetAddressDecodeErrorZ_free(_res_conv);
14484 }
14485
14486 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
14487         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14488         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
14489         return (uint64_t)ret_conv;
14490 }
14491 int64_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
14492         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
14493         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
14494         return ret_val;
14495 }
14496
14497 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
14498         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
14499         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
14500         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
14501         return (uint64_t)ret_conv;
14502 }
14503
14504 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
14505         LDKCVec_UpdateAddHTLCZ _res_constr;
14506         _res_constr.datalen = *((uint32_t*)_res);
14507         if (_res_constr.datalen > 0)
14508                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
14509         else
14510                 _res_constr.data = NULL;
14511         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14512         for (size_t p = 0; p < _res_constr.datalen; p++) {
14513                 uint32_t _res_conv_15 = _res_vals[p];
14514                 LDKUpdateAddHTLC _res_conv_15_conv;
14515                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
14516                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
14517                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
14518                 _res_constr.data[p] = _res_conv_15_conv;
14519         }
14520         CVec_UpdateAddHTLCZ_free(_res_constr);
14521 }
14522
14523 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
14524         LDKCVec_UpdateFulfillHTLCZ _res_constr;
14525         _res_constr.datalen = *((uint32_t*)_res);
14526         if (_res_constr.datalen > 0)
14527                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
14528         else
14529                 _res_constr.data = NULL;
14530         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14531         for (size_t t = 0; t < _res_constr.datalen; t++) {
14532                 uint32_t _res_conv_19 = _res_vals[t];
14533                 LDKUpdateFulfillHTLC _res_conv_19_conv;
14534                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
14535                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
14536                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
14537                 _res_constr.data[t] = _res_conv_19_conv;
14538         }
14539         CVec_UpdateFulfillHTLCZ_free(_res_constr);
14540 }
14541
14542 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
14543         LDKCVec_UpdateFailHTLCZ _res_constr;
14544         _res_constr.datalen = *((uint32_t*)_res);
14545         if (_res_constr.datalen > 0)
14546                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
14547         else
14548                 _res_constr.data = NULL;
14549         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14550         for (size_t q = 0; q < _res_constr.datalen; q++) {
14551                 uint32_t _res_conv_16 = _res_vals[q];
14552                 LDKUpdateFailHTLC _res_conv_16_conv;
14553                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14554                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14555                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14556                 _res_constr.data[q] = _res_conv_16_conv;
14557         }
14558         CVec_UpdateFailHTLCZ_free(_res_constr);
14559 }
14560
14561 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
14562         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
14563         _res_constr.datalen = *((uint32_t*)_res);
14564         if (_res_constr.datalen > 0)
14565                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
14566         else
14567                 _res_constr.data = NULL;
14568         uint32_t* _res_vals = (uint32_t*)(_res + 4);
14569         for (size_t z = 0; z < _res_constr.datalen; z++) {
14570                 uint32_t _res_conv_25 = _res_vals[z];
14571                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
14572                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
14573                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
14574                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
14575                 _res_constr.data[z] = _res_conv_25_conv;
14576         }
14577         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
14578 }
14579
14580 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
14581         LDKAcceptChannel o_conv;
14582         o_conv.inner = (void*)(o & (~1));
14583         o_conv.is_owned = (o & 1) || (o == 0);
14584         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14585         o_conv = AcceptChannel_clone(&o_conv);
14586         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14587         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
14588         return (uint64_t)ret_conv;
14589 }
14590
14591 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
14592         LDKDecodeError e_conv;
14593         e_conv.inner = (void*)(e & (~1));
14594         e_conv.is_owned = (e & 1) || (e == 0);
14595         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14596         e_conv = DecodeError_clone(&e_conv);
14597         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14598         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
14599         return (uint64_t)ret_conv;
14600 }
14601
14602 jboolean  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
14603         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
14604         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
14605         return ret_val;
14606 }
14607
14608 void  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
14609         if ((_res & 1) != 0) return;
14610         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14611         CHECK_ACCESS(_res_ptr);
14612         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
14613         FREE((void*)_res);
14614         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
14615 }
14616
14617 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
14618         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14619         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
14620         return (uint64_t)ret_conv;
14621 }
14622 int64_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
14623         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
14624         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
14625         return ret_val;
14626 }
14627
14628 uint32_t  __attribute__((visibility("default"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
14629         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
14630         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
14631         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
14632         return (uint64_t)ret_conv;
14633 }
14634
14635 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
14636         LDKAnnouncementSignatures o_conv;
14637         o_conv.inner = (void*)(o & (~1));
14638         o_conv.is_owned = (o & 1) || (o == 0);
14639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14640         o_conv = AnnouncementSignatures_clone(&o_conv);
14641         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14642         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
14643         return (uint64_t)ret_conv;
14644 }
14645
14646 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
14647         LDKDecodeError e_conv;
14648         e_conv.inner = (void*)(e & (~1));
14649         e_conv.is_owned = (e & 1) || (e == 0);
14650         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14651         e_conv = DecodeError_clone(&e_conv);
14652         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14653         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
14654         return (uint64_t)ret_conv;
14655 }
14656
14657 jboolean  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
14658         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
14659         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
14660         return ret_val;
14661 }
14662
14663 void  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
14664         if ((_res & 1) != 0) return;
14665         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14666         CHECK_ACCESS(_res_ptr);
14667         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
14668         FREE((void*)_res);
14669         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
14670 }
14671
14672 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
14673         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14674         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
14675         return (uint64_t)ret_conv;
14676 }
14677 int64_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
14678         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
14679         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
14680         return ret_val;
14681 }
14682
14683 uint32_t  __attribute__((visibility("default"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
14684         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
14685         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
14686         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
14687         return (uint64_t)ret_conv;
14688 }
14689
14690 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
14691         LDKChannelReestablish o_conv;
14692         o_conv.inner = (void*)(o & (~1));
14693         o_conv.is_owned = (o & 1) || (o == 0);
14694         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14695         o_conv = ChannelReestablish_clone(&o_conv);
14696         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14697         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
14698         return (uint64_t)ret_conv;
14699 }
14700
14701 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
14702         LDKDecodeError e_conv;
14703         e_conv.inner = (void*)(e & (~1));
14704         e_conv.is_owned = (e & 1) || (e == 0);
14705         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14706         e_conv = DecodeError_clone(&e_conv);
14707         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14708         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
14709         return (uint64_t)ret_conv;
14710 }
14711
14712 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
14713         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
14714         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
14715         return ret_val;
14716 }
14717
14718 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
14719         if ((_res & 1) != 0) return;
14720         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14721         CHECK_ACCESS(_res_ptr);
14722         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
14723         FREE((void*)_res);
14724         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
14725 }
14726
14727 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
14728         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14729         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
14730         return (uint64_t)ret_conv;
14731 }
14732 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
14733         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
14734         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
14735         return ret_val;
14736 }
14737
14738 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
14739         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
14740         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
14741         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
14742         return (uint64_t)ret_conv;
14743 }
14744
14745 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
14746         LDKClosingSigned o_conv;
14747         o_conv.inner = (void*)(o & (~1));
14748         o_conv.is_owned = (o & 1) || (o == 0);
14749         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14750         o_conv = ClosingSigned_clone(&o_conv);
14751         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14752         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
14753         return (uint64_t)ret_conv;
14754 }
14755
14756 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
14757         LDKDecodeError e_conv;
14758         e_conv.inner = (void*)(e & (~1));
14759         e_conv.is_owned = (e & 1) || (e == 0);
14760         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14761         e_conv = DecodeError_clone(&e_conv);
14762         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14763         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
14764         return (uint64_t)ret_conv;
14765 }
14766
14767 jboolean  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
14768         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
14769         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
14770         return ret_val;
14771 }
14772
14773 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
14774         if ((_res & 1) != 0) return;
14775         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14776         CHECK_ACCESS(_res_ptr);
14777         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
14778         FREE((void*)_res);
14779         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
14780 }
14781
14782 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
14783         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14784         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
14785         return (uint64_t)ret_conv;
14786 }
14787 int64_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
14788         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
14789         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
14790         return ret_val;
14791 }
14792
14793 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
14794         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
14795         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
14796         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
14797         return (uint64_t)ret_conv;
14798 }
14799
14800 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
14801         LDKClosingSignedFeeRange o_conv;
14802         o_conv.inner = (void*)(o & (~1));
14803         o_conv.is_owned = (o & 1) || (o == 0);
14804         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14805         o_conv = ClosingSignedFeeRange_clone(&o_conv);
14806         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14807         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
14808         return (uint64_t)ret_conv;
14809 }
14810
14811 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
14812         LDKDecodeError e_conv;
14813         e_conv.inner = (void*)(e & (~1));
14814         e_conv.is_owned = (e & 1) || (e == 0);
14815         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14816         e_conv = DecodeError_clone(&e_conv);
14817         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14818         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
14819         return (uint64_t)ret_conv;
14820 }
14821
14822 jboolean  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
14823         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
14824         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
14825         return ret_val;
14826 }
14827
14828 void  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
14829         if ((_res & 1) != 0) return;
14830         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14831         CHECK_ACCESS(_res_ptr);
14832         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
14833         FREE((void*)_res);
14834         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
14835 }
14836
14837 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
14838         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14839         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
14840         return (uint64_t)ret_conv;
14841 }
14842 int64_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14843         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
14844         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
14845         return ret_val;
14846 }
14847
14848 uint32_t  __attribute__((visibility("default"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
14849         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
14850         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
14851         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
14852         return (uint64_t)ret_conv;
14853 }
14854
14855 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
14856         LDKCommitmentSigned o_conv;
14857         o_conv.inner = (void*)(o & (~1));
14858         o_conv.is_owned = (o & 1) || (o == 0);
14859         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14860         o_conv = CommitmentSigned_clone(&o_conv);
14861         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14862         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
14863         return (uint64_t)ret_conv;
14864 }
14865
14866 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
14867         LDKDecodeError e_conv;
14868         e_conv.inner = (void*)(e & (~1));
14869         e_conv.is_owned = (e & 1) || (e == 0);
14870         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14871         e_conv = DecodeError_clone(&e_conv);
14872         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14873         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
14874         return (uint64_t)ret_conv;
14875 }
14876
14877 jboolean  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
14878         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
14879         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
14880         return ret_val;
14881 }
14882
14883 void  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
14884         if ((_res & 1) != 0) return;
14885         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14886         CHECK_ACCESS(_res_ptr);
14887         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
14888         FREE((void*)_res);
14889         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
14890 }
14891
14892 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
14893         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14894         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
14895         return (uint64_t)ret_conv;
14896 }
14897 int64_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
14898         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
14899         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
14900         return ret_val;
14901 }
14902
14903 uint32_t  __attribute__((visibility("default"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
14904         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
14905         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
14906         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
14907         return (uint64_t)ret_conv;
14908 }
14909
14910 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
14911         LDKFundingCreated o_conv;
14912         o_conv.inner = (void*)(o & (~1));
14913         o_conv.is_owned = (o & 1) || (o == 0);
14914         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14915         o_conv = FundingCreated_clone(&o_conv);
14916         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14917         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
14918         return (uint64_t)ret_conv;
14919 }
14920
14921 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
14922         LDKDecodeError e_conv;
14923         e_conv.inner = (void*)(e & (~1));
14924         e_conv.is_owned = (e & 1) || (e == 0);
14925         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14926         e_conv = DecodeError_clone(&e_conv);
14927         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14928         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
14929         return (uint64_t)ret_conv;
14930 }
14931
14932 jboolean  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
14933         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
14934         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
14935         return ret_val;
14936 }
14937
14938 void  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
14939         if ((_res & 1) != 0) return;
14940         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14941         CHECK_ACCESS(_res_ptr);
14942         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
14943         FREE((void*)_res);
14944         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
14945 }
14946
14947 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
14948         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14949         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
14950         return (uint64_t)ret_conv;
14951 }
14952 int64_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
14953         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
14954         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
14955         return ret_val;
14956 }
14957
14958 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
14959         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
14960         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
14961         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
14962         return (uint64_t)ret_conv;
14963 }
14964
14965 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
14966         LDKFundingSigned o_conv;
14967         o_conv.inner = (void*)(o & (~1));
14968         o_conv.is_owned = (o & 1) || (o == 0);
14969         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14970         o_conv = FundingSigned_clone(&o_conv);
14971         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14972         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
14973         return (uint64_t)ret_conv;
14974 }
14975
14976 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
14977         LDKDecodeError e_conv;
14978         e_conv.inner = (void*)(e & (~1));
14979         e_conv.is_owned = (e & 1) || (e == 0);
14980         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14981         e_conv = DecodeError_clone(&e_conv);
14982         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
14983         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
14984         return (uint64_t)ret_conv;
14985 }
14986
14987 jboolean  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
14988         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
14989         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
14990         return ret_val;
14991 }
14992
14993 void  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
14994         if ((_res & 1) != 0) return;
14995         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14996         CHECK_ACCESS(_res_ptr);
14997         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
14998         FREE((void*)_res);
14999         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
15000 }
15001
15002 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
15003         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
15004         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
15005         return (uint64_t)ret_conv;
15006 }
15007 int64_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
15008         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
15009         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
15010         return ret_val;
15011 }
15012
15013 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
15014         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
15015         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
15016         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
15017         return (uint64_t)ret_conv;
15018 }
15019
15020 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
15021         LDKFundingLocked o_conv;
15022         o_conv.inner = (void*)(o & (~1));
15023         o_conv.is_owned = (o & 1) || (o == 0);
15024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15025         o_conv = FundingLocked_clone(&o_conv);
15026         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15027         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
15028         return (uint64_t)ret_conv;
15029 }
15030
15031 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
15032         LDKDecodeError e_conv;
15033         e_conv.inner = (void*)(e & (~1));
15034         e_conv.is_owned = (e & 1) || (e == 0);
15035         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15036         e_conv = DecodeError_clone(&e_conv);
15037         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15038         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
15039         return (uint64_t)ret_conv;
15040 }
15041
15042 jboolean  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
15043         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
15044         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
15045         return ret_val;
15046 }
15047
15048 void  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
15049         if ((_res & 1) != 0) return;
15050         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15051         CHECK_ACCESS(_res_ptr);
15052         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
15053         FREE((void*)_res);
15054         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
15055 }
15056
15057 static inline uint64_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
15058         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15059         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
15060         return (uint64_t)ret_conv;
15061 }
15062 int64_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
15063         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
15064         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
15065         return ret_val;
15066 }
15067
15068 uint32_t  __attribute__((visibility("default"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
15069         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
15070         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
15071         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
15072         return (uint64_t)ret_conv;
15073 }
15074
15075 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
15076         LDKInit o_conv;
15077         o_conv.inner = (void*)(o & (~1));
15078         o_conv.is_owned = (o & 1) || (o == 0);
15079         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15080         o_conv = Init_clone(&o_conv);
15081         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15082         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
15083         return (uint64_t)ret_conv;
15084 }
15085
15086 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
15087         LDKDecodeError e_conv;
15088         e_conv.inner = (void*)(e & (~1));
15089         e_conv.is_owned = (e & 1) || (e == 0);
15090         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15091         e_conv = DecodeError_clone(&e_conv);
15092         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15093         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
15094         return (uint64_t)ret_conv;
15095 }
15096
15097 jboolean  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
15098         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
15099         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
15100         return ret_val;
15101 }
15102
15103 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
15104         if ((_res & 1) != 0) return;
15105         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15106         CHECK_ACCESS(_res_ptr);
15107         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
15108         FREE((void*)_res);
15109         CResult_InitDecodeErrorZ_free(_res_conv);
15110 }
15111
15112 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
15113         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15114         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
15115         return (uint64_t)ret_conv;
15116 }
15117 int64_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
15118         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
15119         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
15120         return ret_val;
15121 }
15122
15123 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
15124         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
15125         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
15126         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
15127         return (uint64_t)ret_conv;
15128 }
15129
15130 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
15131         LDKOpenChannel o_conv;
15132         o_conv.inner = (void*)(o & (~1));
15133         o_conv.is_owned = (o & 1) || (o == 0);
15134         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15135         o_conv = OpenChannel_clone(&o_conv);
15136         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15137         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
15138         return (uint64_t)ret_conv;
15139 }
15140
15141 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
15142         LDKDecodeError e_conv;
15143         e_conv.inner = (void*)(e & (~1));
15144         e_conv.is_owned = (e & 1) || (e == 0);
15145         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15146         e_conv = DecodeError_clone(&e_conv);
15147         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15148         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
15149         return (uint64_t)ret_conv;
15150 }
15151
15152 jboolean  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
15153         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
15154         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
15155         return ret_val;
15156 }
15157
15158 void  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
15159         if ((_res & 1) != 0) return;
15160         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15161         CHECK_ACCESS(_res_ptr);
15162         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
15163         FREE((void*)_res);
15164         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
15165 }
15166
15167 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
15168         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15169         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
15170         return (uint64_t)ret_conv;
15171 }
15172 int64_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
15173         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
15174         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
15175         return ret_val;
15176 }
15177
15178 uint32_t  __attribute__((visibility("default"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
15179         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
15180         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
15181         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
15182         return (uint64_t)ret_conv;
15183 }
15184
15185 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
15186         LDKRevokeAndACK o_conv;
15187         o_conv.inner = (void*)(o & (~1));
15188         o_conv.is_owned = (o & 1) || (o == 0);
15189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15190         o_conv = RevokeAndACK_clone(&o_conv);
15191         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15192         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
15193         return (uint64_t)ret_conv;
15194 }
15195
15196 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
15197         LDKDecodeError e_conv;
15198         e_conv.inner = (void*)(e & (~1));
15199         e_conv.is_owned = (e & 1) || (e == 0);
15200         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15201         e_conv = DecodeError_clone(&e_conv);
15202         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15203         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
15204         return (uint64_t)ret_conv;
15205 }
15206
15207 jboolean  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
15208         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
15209         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
15210         return ret_val;
15211 }
15212
15213 void  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
15214         if ((_res & 1) != 0) return;
15215         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15216         CHECK_ACCESS(_res_ptr);
15217         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
15218         FREE((void*)_res);
15219         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
15220 }
15221
15222 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
15223         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15224         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
15225         return (uint64_t)ret_conv;
15226 }
15227 int64_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
15228         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
15229         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
15230         return ret_val;
15231 }
15232
15233 uint32_t  __attribute__((visibility("default"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
15234         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
15235         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
15236         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
15237         return (uint64_t)ret_conv;
15238 }
15239
15240 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
15241         LDKShutdown o_conv;
15242         o_conv.inner = (void*)(o & (~1));
15243         o_conv.is_owned = (o & 1) || (o == 0);
15244         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15245         o_conv = Shutdown_clone(&o_conv);
15246         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15247         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
15248         return (uint64_t)ret_conv;
15249 }
15250
15251 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
15252         LDKDecodeError e_conv;
15253         e_conv.inner = (void*)(e & (~1));
15254         e_conv.is_owned = (e & 1) || (e == 0);
15255         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15256         e_conv = DecodeError_clone(&e_conv);
15257         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15258         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
15259         return (uint64_t)ret_conv;
15260 }
15261
15262 jboolean  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
15263         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
15264         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
15265         return ret_val;
15266 }
15267
15268 void  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
15269         if ((_res & 1) != 0) return;
15270         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15271         CHECK_ACCESS(_res_ptr);
15272         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
15273         FREE((void*)_res);
15274         CResult_ShutdownDecodeErrorZ_free(_res_conv);
15275 }
15276
15277 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
15278         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15279         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
15280         return (uint64_t)ret_conv;
15281 }
15282 int64_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
15283         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
15284         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
15285         return ret_val;
15286 }
15287
15288 uint32_t  __attribute__((visibility("default"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
15289         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
15290         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
15291         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
15292         return (uint64_t)ret_conv;
15293 }
15294
15295 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
15296         LDKUpdateFailHTLC o_conv;
15297         o_conv.inner = (void*)(o & (~1));
15298         o_conv.is_owned = (o & 1) || (o == 0);
15299         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15300         o_conv = UpdateFailHTLC_clone(&o_conv);
15301         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15302         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
15303         return (uint64_t)ret_conv;
15304 }
15305
15306 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
15307         LDKDecodeError e_conv;
15308         e_conv.inner = (void*)(e & (~1));
15309         e_conv.is_owned = (e & 1) || (e == 0);
15310         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15311         e_conv = DecodeError_clone(&e_conv);
15312         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15313         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
15314         return (uint64_t)ret_conv;
15315 }
15316
15317 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
15318         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
15319         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
15320         return ret_val;
15321 }
15322
15323 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
15324         if ((_res & 1) != 0) return;
15325         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15326         CHECK_ACCESS(_res_ptr);
15327         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
15328         FREE((void*)_res);
15329         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
15330 }
15331
15332 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
15333         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15334         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
15335         return (uint64_t)ret_conv;
15336 }
15337 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
15338         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
15339         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
15340         return ret_val;
15341 }
15342
15343 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
15344         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
15345         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
15346         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
15347         return (uint64_t)ret_conv;
15348 }
15349
15350 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
15351         LDKUpdateFailMalformedHTLC o_conv;
15352         o_conv.inner = (void*)(o & (~1));
15353         o_conv.is_owned = (o & 1) || (o == 0);
15354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15355         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
15356         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15357         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
15358         return (uint64_t)ret_conv;
15359 }
15360
15361 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
15362         LDKDecodeError e_conv;
15363         e_conv.inner = (void*)(e & (~1));
15364         e_conv.is_owned = (e & 1) || (e == 0);
15365         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15366         e_conv = DecodeError_clone(&e_conv);
15367         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15368         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
15369         return (uint64_t)ret_conv;
15370 }
15371
15372 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
15373         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
15374         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
15375         return ret_val;
15376 }
15377
15378 void  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
15379         if ((_res & 1) != 0) return;
15380         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15381         CHECK_ACCESS(_res_ptr);
15382         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
15383         FREE((void*)_res);
15384         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
15385 }
15386
15387 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
15388         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15389         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
15390         return (uint64_t)ret_conv;
15391 }
15392 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
15393         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
15394         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
15395         return ret_val;
15396 }
15397
15398 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
15399         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
15400         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
15401         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
15402         return (uint64_t)ret_conv;
15403 }
15404
15405 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
15406         LDKUpdateFee o_conv;
15407         o_conv.inner = (void*)(o & (~1));
15408         o_conv.is_owned = (o & 1) || (o == 0);
15409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15410         o_conv = UpdateFee_clone(&o_conv);
15411         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15412         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
15413         return (uint64_t)ret_conv;
15414 }
15415
15416 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
15417         LDKDecodeError e_conv;
15418         e_conv.inner = (void*)(e & (~1));
15419         e_conv.is_owned = (e & 1) || (e == 0);
15420         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15421         e_conv = DecodeError_clone(&e_conv);
15422         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15423         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
15424         return (uint64_t)ret_conv;
15425 }
15426
15427 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
15428         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
15429         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
15430         return ret_val;
15431 }
15432
15433 void  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
15434         if ((_res & 1) != 0) return;
15435         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15436         CHECK_ACCESS(_res_ptr);
15437         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
15438         FREE((void*)_res);
15439         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
15440 }
15441
15442 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
15443         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15444         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
15445         return (uint64_t)ret_conv;
15446 }
15447 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
15448         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
15449         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
15450         return ret_val;
15451 }
15452
15453 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
15454         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
15455         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
15456         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
15457         return (uint64_t)ret_conv;
15458 }
15459
15460 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
15461         LDKUpdateFulfillHTLC o_conv;
15462         o_conv.inner = (void*)(o & (~1));
15463         o_conv.is_owned = (o & 1) || (o == 0);
15464         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15465         o_conv = UpdateFulfillHTLC_clone(&o_conv);
15466         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15467         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
15468         return (uint64_t)ret_conv;
15469 }
15470
15471 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
15472         LDKDecodeError e_conv;
15473         e_conv.inner = (void*)(e & (~1));
15474         e_conv.is_owned = (e & 1) || (e == 0);
15475         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15476         e_conv = DecodeError_clone(&e_conv);
15477         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15478         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
15479         return (uint64_t)ret_conv;
15480 }
15481
15482 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
15483         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
15484         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
15485         return ret_val;
15486 }
15487
15488 void  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
15489         if ((_res & 1) != 0) return;
15490         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15491         CHECK_ACCESS(_res_ptr);
15492         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
15493         FREE((void*)_res);
15494         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
15495 }
15496
15497 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
15498         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15499         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
15500         return (uint64_t)ret_conv;
15501 }
15502 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
15503         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
15504         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
15505         return ret_val;
15506 }
15507
15508 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
15509         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
15510         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
15511         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
15512         return (uint64_t)ret_conv;
15513 }
15514
15515 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
15516         LDKUpdateAddHTLC o_conv;
15517         o_conv.inner = (void*)(o & (~1));
15518         o_conv.is_owned = (o & 1) || (o == 0);
15519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15520         o_conv = UpdateAddHTLC_clone(&o_conv);
15521         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15522         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
15523         return (uint64_t)ret_conv;
15524 }
15525
15526 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
15527         LDKDecodeError e_conv;
15528         e_conv.inner = (void*)(e & (~1));
15529         e_conv.is_owned = (e & 1) || (e == 0);
15530         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15531         e_conv = DecodeError_clone(&e_conv);
15532         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15533         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
15534         return (uint64_t)ret_conv;
15535 }
15536
15537 jboolean  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
15538         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
15539         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
15540         return ret_val;
15541 }
15542
15543 void  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
15544         if ((_res & 1) != 0) return;
15545         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15546         CHECK_ACCESS(_res_ptr);
15547         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
15548         FREE((void*)_res);
15549         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
15550 }
15551
15552 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
15553         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15554         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
15555         return (uint64_t)ret_conv;
15556 }
15557 int64_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
15558         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
15559         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
15560         return ret_val;
15561 }
15562
15563 uint32_t  __attribute__((visibility("default"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
15564         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
15565         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
15566         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
15567         return (uint64_t)ret_conv;
15568 }
15569
15570 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
15571         LDKPing o_conv;
15572         o_conv.inner = (void*)(o & (~1));
15573         o_conv.is_owned = (o & 1) || (o == 0);
15574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15575         o_conv = Ping_clone(&o_conv);
15576         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15577         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
15578         return (uint64_t)ret_conv;
15579 }
15580
15581 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
15582         LDKDecodeError e_conv;
15583         e_conv.inner = (void*)(e & (~1));
15584         e_conv.is_owned = (e & 1) || (e == 0);
15585         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15586         e_conv = DecodeError_clone(&e_conv);
15587         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15588         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
15589         return (uint64_t)ret_conv;
15590 }
15591
15592 jboolean  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
15593         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
15594         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
15595         return ret_val;
15596 }
15597
15598 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
15599         if ((_res & 1) != 0) return;
15600         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15601         CHECK_ACCESS(_res_ptr);
15602         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
15603         FREE((void*)_res);
15604         CResult_PingDecodeErrorZ_free(_res_conv);
15605 }
15606
15607 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
15608         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15609         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
15610         return (uint64_t)ret_conv;
15611 }
15612 int64_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
15613         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
15614         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
15615         return ret_val;
15616 }
15617
15618 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
15619         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
15620         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
15621         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
15622         return (uint64_t)ret_conv;
15623 }
15624
15625 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
15626         LDKPong o_conv;
15627         o_conv.inner = (void*)(o & (~1));
15628         o_conv.is_owned = (o & 1) || (o == 0);
15629         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15630         o_conv = Pong_clone(&o_conv);
15631         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15632         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
15633         return (uint64_t)ret_conv;
15634 }
15635
15636 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
15637         LDKDecodeError e_conv;
15638         e_conv.inner = (void*)(e & (~1));
15639         e_conv.is_owned = (e & 1) || (e == 0);
15640         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15641         e_conv = DecodeError_clone(&e_conv);
15642         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15643         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
15644         return (uint64_t)ret_conv;
15645 }
15646
15647 jboolean  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
15648         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
15649         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
15650         return ret_val;
15651 }
15652
15653 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
15654         if ((_res & 1) != 0) return;
15655         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15656         CHECK_ACCESS(_res_ptr);
15657         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
15658         FREE((void*)_res);
15659         CResult_PongDecodeErrorZ_free(_res_conv);
15660 }
15661
15662 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
15663         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15664         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
15665         return (uint64_t)ret_conv;
15666 }
15667 int64_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
15668         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
15669         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
15670         return ret_val;
15671 }
15672
15673 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
15674         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
15675         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
15676         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
15677         return (uint64_t)ret_conv;
15678 }
15679
15680 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
15681         LDKUnsignedChannelAnnouncement o_conv;
15682         o_conv.inner = (void*)(o & (~1));
15683         o_conv.is_owned = (o & 1) || (o == 0);
15684         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15685         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
15686         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15687         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
15688         return (uint64_t)ret_conv;
15689 }
15690
15691 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
15692         LDKDecodeError e_conv;
15693         e_conv.inner = (void*)(e & (~1));
15694         e_conv.is_owned = (e & 1) || (e == 0);
15695         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15696         e_conv = DecodeError_clone(&e_conv);
15697         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15698         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
15699         return (uint64_t)ret_conv;
15700 }
15701
15702 jboolean  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15703         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
15704         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
15705         return ret_val;
15706 }
15707
15708 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
15709         if ((_res & 1) != 0) return;
15710         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15711         CHECK_ACCESS(_res_ptr);
15712         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
15713         FREE((void*)_res);
15714         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
15715 }
15716
15717 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15718         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15719         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
15720         return (uint64_t)ret_conv;
15721 }
15722 int64_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15723         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
15724         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
15725         return ret_val;
15726 }
15727
15728 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
15729         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
15730         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
15731         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
15732         return (uint64_t)ret_conv;
15733 }
15734
15735 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
15736         LDKChannelAnnouncement o_conv;
15737         o_conv.inner = (void*)(o & (~1));
15738         o_conv.is_owned = (o & 1) || (o == 0);
15739         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15740         o_conv = ChannelAnnouncement_clone(&o_conv);
15741         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15742         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
15743         return (uint64_t)ret_conv;
15744 }
15745
15746 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
15747         LDKDecodeError e_conv;
15748         e_conv.inner = (void*)(e & (~1));
15749         e_conv.is_owned = (e & 1) || (e == 0);
15750         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15751         e_conv = DecodeError_clone(&e_conv);
15752         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15753         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
15754         return (uint64_t)ret_conv;
15755 }
15756
15757 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15758         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
15759         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
15760         return ret_val;
15761 }
15762
15763 void  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
15764         if ((_res & 1) != 0) return;
15765         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15766         CHECK_ACCESS(_res_ptr);
15767         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
15768         FREE((void*)_res);
15769         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
15770 }
15771
15772 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15773         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15774         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
15775         return (uint64_t)ret_conv;
15776 }
15777 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15778         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
15779         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
15780         return ret_val;
15781 }
15782
15783 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
15784         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
15785         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
15786         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
15787         return (uint64_t)ret_conv;
15788 }
15789
15790 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
15791         LDKUnsignedChannelUpdate o_conv;
15792         o_conv.inner = (void*)(o & (~1));
15793         o_conv.is_owned = (o & 1) || (o == 0);
15794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15795         o_conv = UnsignedChannelUpdate_clone(&o_conv);
15796         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15797         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
15798         return (uint64_t)ret_conv;
15799 }
15800
15801 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
15802         LDKDecodeError e_conv;
15803         e_conv.inner = (void*)(e & (~1));
15804         e_conv.is_owned = (e & 1) || (e == 0);
15805         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15806         e_conv = DecodeError_clone(&e_conv);
15807         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15808         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
15809         return (uint64_t)ret_conv;
15810 }
15811
15812 jboolean  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
15813         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
15814         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
15815         return ret_val;
15816 }
15817
15818 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
15819         if ((_res & 1) != 0) return;
15820         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15821         CHECK_ACCESS(_res_ptr);
15822         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
15823         FREE((void*)_res);
15824         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
15825 }
15826
15827 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
15828         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15829         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
15830         return (uint64_t)ret_conv;
15831 }
15832 int64_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15833         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
15834         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
15835         return ret_val;
15836 }
15837
15838 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
15839         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
15840         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
15841         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
15842         return (uint64_t)ret_conv;
15843 }
15844
15845 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
15846         LDKChannelUpdate o_conv;
15847         o_conv.inner = (void*)(o & (~1));
15848         o_conv.is_owned = (o & 1) || (o == 0);
15849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15850         o_conv = ChannelUpdate_clone(&o_conv);
15851         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15852         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
15853         return (uint64_t)ret_conv;
15854 }
15855
15856 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
15857         LDKDecodeError e_conv;
15858         e_conv.inner = (void*)(e & (~1));
15859         e_conv.is_owned = (e & 1) || (e == 0);
15860         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15861         e_conv = DecodeError_clone(&e_conv);
15862         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15863         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
15864         return (uint64_t)ret_conv;
15865 }
15866
15867 jboolean  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
15868         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
15869         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
15870         return ret_val;
15871 }
15872
15873 void  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
15874         if ((_res & 1) != 0) return;
15875         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15876         CHECK_ACCESS(_res_ptr);
15877         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
15878         FREE((void*)_res);
15879         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
15880 }
15881
15882 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
15883         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15884         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
15885         return (uint64_t)ret_conv;
15886 }
15887 int64_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15888         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
15889         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
15890         return ret_val;
15891 }
15892
15893 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
15894         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
15895         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
15896         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
15897         return (uint64_t)ret_conv;
15898 }
15899
15900 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
15901         LDKErrorMessage o_conv;
15902         o_conv.inner = (void*)(o & (~1));
15903         o_conv.is_owned = (o & 1) || (o == 0);
15904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15905         o_conv = ErrorMessage_clone(&o_conv);
15906         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15907         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
15908         return (uint64_t)ret_conv;
15909 }
15910
15911 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
15912         LDKDecodeError e_conv;
15913         e_conv.inner = (void*)(e & (~1));
15914         e_conv.is_owned = (e & 1) || (e == 0);
15915         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15916         e_conv = DecodeError_clone(&e_conv);
15917         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15918         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
15919         return (uint64_t)ret_conv;
15920 }
15921
15922 jboolean  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
15923         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
15924         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
15925         return ret_val;
15926 }
15927
15928 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
15929         if ((_res & 1) != 0) return;
15930         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15931         CHECK_ACCESS(_res_ptr);
15932         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
15933         FREE((void*)_res);
15934         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
15935 }
15936
15937 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
15938         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15939         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
15940         return (uint64_t)ret_conv;
15941 }
15942 int64_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
15943         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
15944         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
15945         return ret_val;
15946 }
15947
15948 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
15949         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
15950         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
15951         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
15952         return (uint64_t)ret_conv;
15953 }
15954
15955 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
15956         LDKUnsignedNodeAnnouncement o_conv;
15957         o_conv.inner = (void*)(o & (~1));
15958         o_conv.is_owned = (o & 1) || (o == 0);
15959         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15960         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
15961         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15962         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
15963         return (uint64_t)ret_conv;
15964 }
15965
15966 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
15967         LDKDecodeError e_conv;
15968         e_conv.inner = (void*)(e & (~1));
15969         e_conv.is_owned = (e & 1) || (e == 0);
15970         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15971         e_conv = DecodeError_clone(&e_conv);
15972         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15973         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
15974         return (uint64_t)ret_conv;
15975 }
15976
15977 jboolean  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
15978         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
15979         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
15980         return ret_val;
15981 }
15982
15983 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
15984         if ((_res & 1) != 0) return;
15985         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15986         CHECK_ACCESS(_res_ptr);
15987         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
15988         FREE((void*)_res);
15989         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
15990 }
15991
15992 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
15993         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
15994         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
15995         return (uint64_t)ret_conv;
15996 }
15997 int64_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
15998         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
15999         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
16000         return ret_val;
16001 }
16002
16003 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
16004         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
16005         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
16006         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
16007         return (uint64_t)ret_conv;
16008 }
16009
16010 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
16011         LDKNodeAnnouncement o_conv;
16012         o_conv.inner = (void*)(o & (~1));
16013         o_conv.is_owned = (o & 1) || (o == 0);
16014         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16015         o_conv = NodeAnnouncement_clone(&o_conv);
16016         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16017         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
16018         return (uint64_t)ret_conv;
16019 }
16020
16021 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
16022         LDKDecodeError e_conv;
16023         e_conv.inner = (void*)(e & (~1));
16024         e_conv.is_owned = (e & 1) || (e == 0);
16025         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16026         e_conv = DecodeError_clone(&e_conv);
16027         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16028         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
16029         return (uint64_t)ret_conv;
16030 }
16031
16032 jboolean  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
16033         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
16034         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
16035         return ret_val;
16036 }
16037
16038 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
16039         if ((_res & 1) != 0) return;
16040         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16041         CHECK_ACCESS(_res_ptr);
16042         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
16043         FREE((void*)_res);
16044         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
16045 }
16046
16047 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
16048         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16049         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
16050         return (uint64_t)ret_conv;
16051 }
16052 int64_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
16053         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
16054         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
16055         return ret_val;
16056 }
16057
16058 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
16059         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
16060         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
16061         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
16062         return (uint64_t)ret_conv;
16063 }
16064
16065 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
16066         LDKQueryShortChannelIds o_conv;
16067         o_conv.inner = (void*)(o & (~1));
16068         o_conv.is_owned = (o & 1) || (o == 0);
16069         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16070         o_conv = QueryShortChannelIds_clone(&o_conv);
16071         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16072         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
16073         return (uint64_t)ret_conv;
16074 }
16075
16076 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
16077         LDKDecodeError e_conv;
16078         e_conv.inner = (void*)(e & (~1));
16079         e_conv.is_owned = (e & 1) || (e == 0);
16080         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16081         e_conv = DecodeError_clone(&e_conv);
16082         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16083         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
16084         return (uint64_t)ret_conv;
16085 }
16086
16087 jboolean  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
16088         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
16089         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
16090         return ret_val;
16091 }
16092
16093 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
16094         if ((_res & 1) != 0) return;
16095         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16096         CHECK_ACCESS(_res_ptr);
16097         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
16098         FREE((void*)_res);
16099         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
16100 }
16101
16102 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
16103         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16104         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
16105         return (uint64_t)ret_conv;
16106 }
16107 int64_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
16108         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
16109         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
16110         return ret_val;
16111 }
16112
16113 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
16114         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
16115         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
16116         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
16117         return (uint64_t)ret_conv;
16118 }
16119
16120 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
16121         LDKReplyShortChannelIdsEnd o_conv;
16122         o_conv.inner = (void*)(o & (~1));
16123         o_conv.is_owned = (o & 1) || (o == 0);
16124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16125         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
16126         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16127         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
16128         return (uint64_t)ret_conv;
16129 }
16130
16131 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
16132         LDKDecodeError e_conv;
16133         e_conv.inner = (void*)(e & (~1));
16134         e_conv.is_owned = (e & 1) || (e == 0);
16135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16136         e_conv = DecodeError_clone(&e_conv);
16137         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16138         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
16139         return (uint64_t)ret_conv;
16140 }
16141
16142 jboolean  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
16143         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
16144         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
16145         return ret_val;
16146 }
16147
16148 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
16149         if ((_res & 1) != 0) return;
16150         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16151         CHECK_ACCESS(_res_ptr);
16152         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
16153         FREE((void*)_res);
16154         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
16155 }
16156
16157 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
16158         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16159         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
16160         return (uint64_t)ret_conv;
16161 }
16162 int64_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
16163         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
16164         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
16165         return ret_val;
16166 }
16167
16168 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
16169         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
16170         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
16171         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
16172         return (uint64_t)ret_conv;
16173 }
16174
16175 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
16176         LDKQueryChannelRange o_conv;
16177         o_conv.inner = (void*)(o & (~1));
16178         o_conv.is_owned = (o & 1) || (o == 0);
16179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16180         o_conv = QueryChannelRange_clone(&o_conv);
16181         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16182         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
16183         return (uint64_t)ret_conv;
16184 }
16185
16186 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
16187         LDKDecodeError e_conv;
16188         e_conv.inner = (void*)(e & (~1));
16189         e_conv.is_owned = (e & 1) || (e == 0);
16190         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16191         e_conv = DecodeError_clone(&e_conv);
16192         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16193         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
16194         return (uint64_t)ret_conv;
16195 }
16196
16197 jboolean  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
16198         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
16199         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
16200         return ret_val;
16201 }
16202
16203 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
16204         if ((_res & 1) != 0) return;
16205         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16206         CHECK_ACCESS(_res_ptr);
16207         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
16208         FREE((void*)_res);
16209         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
16210 }
16211
16212 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
16213         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16214         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
16215         return (uint64_t)ret_conv;
16216 }
16217 int64_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
16218         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
16219         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
16220         return ret_val;
16221 }
16222
16223 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
16224         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
16225         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
16226         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
16227         return (uint64_t)ret_conv;
16228 }
16229
16230 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
16231         LDKReplyChannelRange o_conv;
16232         o_conv.inner = (void*)(o & (~1));
16233         o_conv.is_owned = (o & 1) || (o == 0);
16234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16235         o_conv = ReplyChannelRange_clone(&o_conv);
16236         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16237         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
16238         return (uint64_t)ret_conv;
16239 }
16240
16241 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
16242         LDKDecodeError e_conv;
16243         e_conv.inner = (void*)(e & (~1));
16244         e_conv.is_owned = (e & 1) || (e == 0);
16245         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16246         e_conv = DecodeError_clone(&e_conv);
16247         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16248         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
16249         return (uint64_t)ret_conv;
16250 }
16251
16252 jboolean  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
16253         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
16254         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
16255         return ret_val;
16256 }
16257
16258 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
16259         if ((_res & 1) != 0) return;
16260         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16261         CHECK_ACCESS(_res_ptr);
16262         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
16263         FREE((void*)_res);
16264         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
16265 }
16266
16267 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
16268         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16269         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
16270         return (uint64_t)ret_conv;
16271 }
16272 int64_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
16273         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
16274         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
16275         return ret_val;
16276 }
16277
16278 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
16279         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
16280         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
16281         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
16282         return (uint64_t)ret_conv;
16283 }
16284
16285 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
16286         LDKGossipTimestampFilter o_conv;
16287         o_conv.inner = (void*)(o & (~1));
16288         o_conv.is_owned = (o & 1) || (o == 0);
16289         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16290         o_conv = GossipTimestampFilter_clone(&o_conv);
16291         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16292         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
16293         return (uint64_t)ret_conv;
16294 }
16295
16296 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
16297         LDKDecodeError e_conv;
16298         e_conv.inner = (void*)(e & (~1));
16299         e_conv.is_owned = (e & 1) || (e == 0);
16300         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16301         e_conv = DecodeError_clone(&e_conv);
16302         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16303         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
16304         return (uint64_t)ret_conv;
16305 }
16306
16307 jboolean  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
16308         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
16309         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
16310         return ret_val;
16311 }
16312
16313 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
16314         if ((_res & 1) != 0) return;
16315         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16316         CHECK_ACCESS(_res_ptr);
16317         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
16318         FREE((void*)_res);
16319         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
16320 }
16321
16322 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
16323         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16324         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
16325         return (uint64_t)ret_conv;
16326 }
16327 int64_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
16328         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
16329         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
16330         return ret_val;
16331 }
16332
16333 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
16334         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
16335         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
16336         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
16337         return (uint64_t)ret_conv;
16338 }
16339
16340 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
16341         LDKInvoice o_conv;
16342         o_conv.inner = (void*)(o & (~1));
16343         o_conv.is_owned = (o & 1) || (o == 0);
16344         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16345         o_conv = Invoice_clone(&o_conv);
16346         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16347         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
16348         return (uint64_t)ret_conv;
16349 }
16350
16351 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
16352         void* e_ptr = (void*)(((uint64_t)e) & ~1);
16353         CHECK_ACCESS(e_ptr);
16354         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
16355         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
16356         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16357         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
16358         return (uint64_t)ret_conv;
16359 }
16360
16361 jboolean  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
16362         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
16363         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
16364         return ret_val;
16365 }
16366
16367 void  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
16368         if ((_res & 1) != 0) return;
16369         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16370         CHECK_ACCESS(_res_ptr);
16371         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
16372         FREE((void*)_res);
16373         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
16374 }
16375
16376 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
16377         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16378         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
16379         return (uint64_t)ret_conv;
16380 }
16381 int64_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
16382         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
16383         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
16384         return ret_val;
16385 }
16386
16387 uint32_t  __attribute__((visibility("default"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
16388         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
16389         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
16390         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
16391         return (uint64_t)ret_conv;
16392 }
16393
16394 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_some(uint32_t o) {
16395         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16396         CHECK_ACCESS(o_ptr);
16397         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
16398         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
16399         *ret_copy = COption_FilterZ_some(o_conv);
16400         uint64_t ret_ref = (uint64_t)ret_copy;
16401         return ret_ref;
16402 }
16403
16404 uint32_t  __attribute__((visibility("default"))) TS_COption_FilterZ_none() {
16405         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
16406         *ret_copy = COption_FilterZ_none();
16407         uint64_t ret_ref = (uint64_t)ret_copy;
16408         return ret_ref;
16409 }
16410
16411 void  __attribute__((visibility("default"))) TS_COption_FilterZ_free(uint32_t _res) {
16412         if ((_res & 1) != 0) return;
16413         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16414         CHECK_ACCESS(_res_ptr);
16415         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
16416         FREE((void*)_res);
16417         COption_FilterZ_free(_res_conv);
16418 }
16419
16420 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
16421         LDKLockedChannelMonitor o_conv;
16422         o_conv.inner = (void*)(o & (~1));
16423         o_conv.is_owned = (o & 1) || (o == 0);
16424         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16425         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
16426         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
16427         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
16428         return (uint64_t)ret_conv;
16429 }
16430
16431 uint32_t  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
16432         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
16433         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
16434         return (uint64_t)ret_conv;
16435 }
16436
16437 jboolean  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
16438         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
16439         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
16440         return ret_val;
16441 }
16442
16443 void  __attribute__((visibility("default"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
16444         if ((_res & 1) != 0) return;
16445         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16446         CHECK_ACCESS(_res_ptr);
16447         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
16448         FREE((void*)_res);
16449         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
16450 }
16451
16452 void  __attribute__((visibility("default"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
16453         LDKCVec_OutPointZ _res_constr;
16454         _res_constr.datalen = *((uint32_t*)_res);
16455         if (_res_constr.datalen > 0)
16456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
16457         else
16458                 _res_constr.data = NULL;
16459         uint32_t* _res_vals = (uint32_t*)(_res + 4);
16460         for (size_t k = 0; k < _res_constr.datalen; k++) {
16461                 uint32_t _res_conv_10 = _res_vals[k];
16462                 LDKOutPoint _res_conv_10_conv;
16463                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
16464                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
16465                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16466                 _res_constr.data[k] = _res_conv_10_conv;
16467         }
16468         CVec_OutPointZ_free(_res_constr);
16469 }
16470
16471 void  __attribute__((visibility("default"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
16472         if ((this_ptr & 1) != 0) return;
16473         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16474         CHECK_ACCESS(this_ptr_ptr);
16475         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
16476         FREE((void*)this_ptr);
16477         PaymentPurpose_free(this_ptr_conv);
16478 }
16479
16480 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
16481         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16482         *ret_copy = PaymentPurpose_clone(arg);
16483 uint64_t ret_ref = (uint64_t)ret_copy;
16484         return ret_ref;
16485 }
16486 int64_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
16487         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
16488         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
16489         return ret_val;
16490 }
16491
16492 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_clone(uint32_t orig) {
16493         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
16494         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16495         *ret_copy = PaymentPurpose_clone(orig_conv);
16496         uint64_t ret_ref = (uint64_t)ret_copy;
16497         return ret_ref;
16498 }
16499
16500 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
16501         LDKThirtyTwoBytes payment_preimage_ref;
16502         CHECK(*((uint32_t*)payment_preimage) == 32);
16503         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
16504         LDKThirtyTwoBytes payment_secret_ref;
16505         CHECK(*((uint32_t*)payment_secret) == 32);
16506         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
16507         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16508         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
16509         uint64_t ret_ref = (uint64_t)ret_copy;
16510         return ret_ref;
16511 }
16512
16513 uint32_t  __attribute__((visibility("default"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
16514         LDKThirtyTwoBytes a_ref;
16515         CHECK(*((uint32_t*)a) == 32);
16516         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
16517         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16518         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
16519         uint64_t ret_ref = (uint64_t)ret_copy;
16520         return ret_ref;
16521 }
16522
16523 void  __attribute__((visibility("default"))) TS_ClosureReason_free(uint32_t this_ptr) {
16524         if ((this_ptr & 1) != 0) return;
16525         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16526         CHECK_ACCESS(this_ptr_ptr);
16527         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
16528         FREE((void*)this_ptr);
16529         ClosureReason_free(this_ptr_conv);
16530 }
16531
16532 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
16533         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16534         *ret_copy = ClosureReason_clone(arg);
16535 uint64_t ret_ref = (uint64_t)ret_copy;
16536         return ret_ref;
16537 }
16538 int64_t  __attribute__((visibility("default"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
16539         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
16540         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
16541         return ret_val;
16542 }
16543
16544 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_clone(uint32_t orig) {
16545         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
16546         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16547         *ret_copy = ClosureReason_clone(orig_conv);
16548         uint64_t ret_ref = (uint64_t)ret_copy;
16549         return ret_ref;
16550 }
16551
16552 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
16553         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
16554         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16555         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
16556         uint64_t ret_ref = (uint64_t)ret_copy;
16557         return ret_ref;
16558 }
16559
16560 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_holder_force_closed() {
16561         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16562         *ret_copy = ClosureReason_holder_force_closed();
16563         uint64_t ret_ref = (uint64_t)ret_copy;
16564         return ret_ref;
16565 }
16566
16567 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_cooperative_closure() {
16568         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16569         *ret_copy = ClosureReason_cooperative_closure();
16570         uint64_t ret_ref = (uint64_t)ret_copy;
16571         return ret_ref;
16572 }
16573
16574 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_commitment_tx_confirmed() {
16575         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16576         *ret_copy = ClosureReason_commitment_tx_confirmed();
16577         uint64_t ret_ref = (uint64_t)ret_copy;
16578         return ret_ref;
16579 }
16580
16581 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_funding_timed_out() {
16582         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16583         *ret_copy = ClosureReason_funding_timed_out();
16584         uint64_t ret_ref = (uint64_t)ret_copy;
16585         return ret_ref;
16586 }
16587
16588 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_processing_error(jstring err) {
16589         LDKStr err_conv = str_ref_to_owned_c(err);
16590         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16591         *ret_copy = ClosureReason_processing_error(err_conv);
16592         uint64_t ret_ref = (uint64_t)ret_copy;
16593         return ret_ref;
16594 }
16595
16596 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_disconnected_peer() {
16597         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16598         *ret_copy = ClosureReason_disconnected_peer();
16599         uint64_t ret_ref = (uint64_t)ret_copy;
16600         return ret_ref;
16601 }
16602
16603 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_outdated_channel_manager() {
16604         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16605         *ret_copy = ClosureReason_outdated_channel_manager();
16606         uint64_t ret_ref = (uint64_t)ret_copy;
16607         return ret_ref;
16608 }
16609
16610 int8_tArray  __attribute__((visibility("default"))) TS_ClosureReason_write(uint32_t obj) {
16611         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
16612         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
16613         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16614         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16615         CVec_u8Z_free(ret_var);
16616         return ret_arr;
16617 }
16618
16619 uint32_t  __attribute__((visibility("default"))) TS_ClosureReason_read(int8_tArray ser) {
16620         LDKu8slice ser_ref;
16621         ser_ref.datalen = *((uint32_t*)ser);
16622         ser_ref.data = (int8_t*)(ser + 4);
16623         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16624         *ret_conv = ClosureReason_read(ser_ref);
16625         return (uint64_t)ret_conv;
16626 }
16627
16628 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
16629         if ((this_ptr & 1) != 0) return;
16630         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16631         CHECK_ACCESS(this_ptr_ptr);
16632         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
16633         FREE((void*)this_ptr);
16634         Event_free(this_ptr_conv);
16635 }
16636
16637 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
16638         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16639         *ret_copy = Event_clone(arg);
16640 uint64_t ret_ref = (uint64_t)ret_copy;
16641         return ret_ref;
16642 }
16643 int64_t  __attribute__((visibility("default"))) TS_Event_clone_ptr(uint32_t arg) {
16644         LDKEvent* arg_conv = (LDKEvent*)arg;
16645         int64_t ret_val = Event_clone_ptr(arg_conv);
16646         return ret_val;
16647 }
16648
16649 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
16650         LDKEvent* orig_conv = (LDKEvent*)orig;
16651         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16652         *ret_copy = Event_clone(orig_conv);
16653         uint64_t ret_ref = (uint64_t)ret_copy;
16654         return ret_ref;
16655 }
16656
16657 uint32_t  __attribute__((visibility("default"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
16658         LDKThirtyTwoBytes temporary_channel_id_ref;
16659         CHECK(*((uint32_t*)temporary_channel_id) == 32);
16660         memcpy(temporary_channel_id_ref.data, (uint8_t*)(temporary_channel_id + 4), 32);
16661         LDKCVec_u8Z output_script_ref;
16662         output_script_ref.datalen = *((uint32_t*)output_script);
16663         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
16664         memcpy(output_script_ref.data, (uint8_t*)(output_script + 4), output_script_ref.datalen);
16665         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16666         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
16667         uint64_t ret_ref = (uint64_t)ret_copy;
16668         return ret_ref;
16669 }
16670
16671 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
16672         LDKThirtyTwoBytes payment_hash_ref;
16673         CHECK(*((uint32_t*)payment_hash) == 32);
16674         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16675         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
16676         CHECK_ACCESS(purpose_ptr);
16677         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
16678         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
16679         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16680         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
16681         uint64_t ret_ref = (uint64_t)ret_copy;
16682         return ret_ref;
16683 }
16684
16685 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_sent(int8_tArray payment_id, int8_tArray payment_preimage, int8_tArray payment_hash, uint32_t fee_paid_msat) {
16686         LDKThirtyTwoBytes payment_id_ref;
16687         CHECK(*((uint32_t*)payment_id) == 32);
16688         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
16689         LDKThirtyTwoBytes payment_preimage_ref;
16690         CHECK(*((uint32_t*)payment_preimage) == 32);
16691         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
16692         LDKThirtyTwoBytes payment_hash_ref;
16693         CHECK(*((uint32_t*)payment_hash) == 32);
16694         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16695         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
16696         CHECK_ACCESS(fee_paid_msat_ptr);
16697         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
16698         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
16699         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16700         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
16701         uint64_t ret_ref = (uint64_t)ret_copy;
16702         return ret_ref;
16703 }
16704
16705 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_failed(int8_tArray payment_id, int8_tArray payment_hash, jboolean rejected_by_dest, uint32_t network_update, jboolean all_paths_failed, uint32_tArray path, uint32_t short_channel_id, uint32_t retry) {
16706         LDKThirtyTwoBytes payment_id_ref;
16707         CHECK(*((uint32_t*)payment_id) == 32);
16708         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
16709         LDKThirtyTwoBytes payment_hash_ref;
16710         CHECK(*((uint32_t*)payment_hash) == 32);
16711         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16712         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
16713         CHECK_ACCESS(network_update_ptr);
16714         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
16715         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
16716         LDKCVec_RouteHopZ path_constr;
16717         path_constr.datalen = *((uint32_t*)path);
16718         if (path_constr.datalen > 0)
16719                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16720         else
16721                 path_constr.data = NULL;
16722         uint32_t* path_vals = (uint32_t*)(path + 4);
16723         for (size_t k = 0; k < path_constr.datalen; k++) {
16724                 uint32_t path_conv_10 = path_vals[k];
16725                 LDKRouteHop path_conv_10_conv;
16726                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16727                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16728                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16729                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16730                 path_constr.data[k] = path_conv_10_conv;
16731         }
16732         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
16733         CHECK_ACCESS(short_channel_id_ptr);
16734         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
16735         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
16736         LDKRouteParameters retry_conv;
16737         retry_conv.inner = (void*)(retry & (~1));
16738         retry_conv.is_owned = (retry & 1) || (retry == 0);
16739         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
16740         retry_conv = RouteParameters_clone(&retry_conv);
16741         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16742         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
16743         uint64_t ret_ref = (uint64_t)ret_copy;
16744         return ret_ref;
16745 }
16746
16747 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
16748         LDKThirtyTwoBytes payment_id_ref;
16749         CHECK(*((uint32_t*)payment_id) == 32);
16750         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
16751         LDKThirtyTwoBytes payment_hash_ref;
16752         CHECK(*((uint32_t*)payment_hash) == 32);
16753         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16754         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16755         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
16756         uint64_t ret_ref = (uint64_t)ret_copy;
16757         return ret_ref;
16758 }
16759
16760 uint32_t  __attribute__((visibility("default"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
16761         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16762         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
16763         uint64_t ret_ref = (uint64_t)ret_copy;
16764         return ret_ref;
16765 }
16766
16767 uint32_t  __attribute__((visibility("default"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
16768         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
16769         outputs_constr.datalen = *((uint32_t*)outputs);
16770         if (outputs_constr.datalen > 0)
16771                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16772         else
16773                 outputs_constr.data = NULL;
16774         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
16775         for (size_t b = 0; b < outputs_constr.datalen; b++) {
16776                 uint32_t outputs_conv_27 = outputs_vals[b];
16777                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
16778                 CHECK_ACCESS(outputs_conv_27_ptr);
16779                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
16780                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
16781                 outputs_constr.data[b] = outputs_conv_27_conv;
16782         }
16783         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16784         *ret_copy = Event_spendable_outputs(outputs_constr);
16785         uint64_t ret_ref = (uint64_t)ret_copy;
16786         return ret_ref;
16787 }
16788
16789 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
16790         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
16791         CHECK_ACCESS(fee_earned_msat_ptr);
16792         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
16793         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
16794         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16795         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
16796         uint64_t ret_ref = (uint64_t)ret_copy;
16797         return ret_ref;
16798 }
16799
16800 uint32_t  __attribute__((visibility("default"))) TS_Event_channel_closed(int8_tArray channel_id, int64_t user_channel_id, uint32_t reason) {
16801         LDKThirtyTwoBytes channel_id_ref;
16802         CHECK(*((uint32_t*)channel_id) == 32);
16803         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
16804         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
16805         CHECK_ACCESS(reason_ptr);
16806         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
16807         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
16808         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16809         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
16810         uint64_t ret_ref = (uint64_t)ret_copy;
16811         return ret_ref;
16812 }
16813
16814 uint32_t  __attribute__((visibility("default"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
16815         LDKThirtyTwoBytes channel_id_ref;
16816         CHECK(*((uint32_t*)channel_id) == 32);
16817         memcpy(channel_id_ref.data, (uint8_t*)(channel_id + 4), 32);
16818         LDKTransaction transaction_ref;
16819         transaction_ref.datalen = *((uint32_t*)transaction);
16820         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
16821         memcpy(transaction_ref.data, (uint8_t*)(transaction + 4), transaction_ref.datalen);
16822         transaction_ref.data_is_owned = true;
16823         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16824         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
16825         uint64_t ret_ref = (uint64_t)ret_copy;
16826         return ret_ref;
16827 }
16828
16829 uint32_t  __attribute__((visibility("default"))) TS_Event_payment_path_successful(int8_tArray payment_id, int8_tArray payment_hash, uint32_tArray path) {
16830         LDKThirtyTwoBytes payment_id_ref;
16831         CHECK(*((uint32_t*)payment_id) == 32);
16832         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
16833         LDKThirtyTwoBytes payment_hash_ref;
16834         CHECK(*((uint32_t*)payment_hash) == 32);
16835         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
16836         LDKCVec_RouteHopZ path_constr;
16837         path_constr.datalen = *((uint32_t*)path);
16838         if (path_constr.datalen > 0)
16839                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16840         else
16841                 path_constr.data = NULL;
16842         uint32_t* path_vals = (uint32_t*)(path + 4);
16843         for (size_t k = 0; k < path_constr.datalen; k++) {
16844                 uint32_t path_conv_10 = path_vals[k];
16845                 LDKRouteHop path_conv_10_conv;
16846                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16847                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16848                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16849                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16850                 path_constr.data[k] = path_conv_10_conv;
16851         }
16852         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16853         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
16854         uint64_t ret_ref = (uint64_t)ret_copy;
16855         return ret_ref;
16856 }
16857
16858 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
16859         LDKEvent* obj_conv = (LDKEvent*)obj;
16860         LDKCVec_u8Z ret_var = Event_write(obj_conv);
16861         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
16862         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
16863         CVec_u8Z_free(ret_var);
16864         return ret_arr;
16865 }
16866
16867 uint32_t  __attribute__((visibility("default"))) TS_Event_read(int8_tArray ser) {
16868         LDKu8slice ser_ref;
16869         ser_ref.datalen = *((uint32_t*)ser);
16870         ser_ref.data = (int8_t*)(ser + 4);
16871         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16872         *ret_conv = Event_read(ser_ref);
16873         return (uint64_t)ret_conv;
16874 }
16875
16876 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
16877         if ((this_ptr & 1) != 0) return;
16878         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
16879         CHECK_ACCESS(this_ptr_ptr);
16880         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
16881         FREE((void*)this_ptr);
16882         MessageSendEvent_free(this_ptr_conv);
16883 }
16884
16885 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
16886         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16887         *ret_copy = MessageSendEvent_clone(arg);
16888 uint64_t ret_ref = (uint64_t)ret_copy;
16889         return ret_ref;
16890 }
16891 int64_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
16892         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
16893         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
16894         return ret_val;
16895 }
16896
16897 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
16898         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
16899         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16900         *ret_copy = MessageSendEvent_clone(orig_conv);
16901         uint64_t ret_ref = (uint64_t)ret_copy;
16902         return ret_ref;
16903 }
16904
16905 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
16906         LDKPublicKey node_id_ref;
16907         CHECK(*((uint32_t*)node_id) == 33);
16908         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16909         LDKAcceptChannel msg_conv;
16910         msg_conv.inner = (void*)(msg & (~1));
16911         msg_conv.is_owned = (msg & 1) || (msg == 0);
16912         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16913         msg_conv = AcceptChannel_clone(&msg_conv);
16914         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16915         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
16916         uint64_t ret_ref = (uint64_t)ret_copy;
16917         return ret_ref;
16918 }
16919
16920 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
16921         LDKPublicKey node_id_ref;
16922         CHECK(*((uint32_t*)node_id) == 33);
16923         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16924         LDKOpenChannel msg_conv;
16925         msg_conv.inner = (void*)(msg & (~1));
16926         msg_conv.is_owned = (msg & 1) || (msg == 0);
16927         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16928         msg_conv = OpenChannel_clone(&msg_conv);
16929         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16930         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
16931         uint64_t ret_ref = (uint64_t)ret_copy;
16932         return ret_ref;
16933 }
16934
16935 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
16936         LDKPublicKey node_id_ref;
16937         CHECK(*((uint32_t*)node_id) == 33);
16938         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16939         LDKFundingCreated msg_conv;
16940         msg_conv.inner = (void*)(msg & (~1));
16941         msg_conv.is_owned = (msg & 1) || (msg == 0);
16942         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16943         msg_conv = FundingCreated_clone(&msg_conv);
16944         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16945         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
16946         uint64_t ret_ref = (uint64_t)ret_copy;
16947         return ret_ref;
16948 }
16949
16950 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
16951         LDKPublicKey node_id_ref;
16952         CHECK(*((uint32_t*)node_id) == 33);
16953         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16954         LDKFundingSigned msg_conv;
16955         msg_conv.inner = (void*)(msg & (~1));
16956         msg_conv.is_owned = (msg & 1) || (msg == 0);
16957         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16958         msg_conv = FundingSigned_clone(&msg_conv);
16959         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16960         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
16961         uint64_t ret_ref = (uint64_t)ret_copy;
16962         return ret_ref;
16963 }
16964
16965 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
16966         LDKPublicKey node_id_ref;
16967         CHECK(*((uint32_t*)node_id) == 33);
16968         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16969         LDKFundingLocked msg_conv;
16970         msg_conv.inner = (void*)(msg & (~1));
16971         msg_conv.is_owned = (msg & 1) || (msg == 0);
16972         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16973         msg_conv = FundingLocked_clone(&msg_conv);
16974         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16975         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
16976         uint64_t ret_ref = (uint64_t)ret_copy;
16977         return ret_ref;
16978 }
16979
16980 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
16981         LDKPublicKey node_id_ref;
16982         CHECK(*((uint32_t*)node_id) == 33);
16983         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16984         LDKAnnouncementSignatures msg_conv;
16985         msg_conv.inner = (void*)(msg & (~1));
16986         msg_conv.is_owned = (msg & 1) || (msg == 0);
16987         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16988         msg_conv = AnnouncementSignatures_clone(&msg_conv);
16989         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16990         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
16991         uint64_t ret_ref = (uint64_t)ret_copy;
16992         return ret_ref;
16993 }
16994
16995 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
16996         LDKPublicKey node_id_ref;
16997         CHECK(*((uint32_t*)node_id) == 33);
16998         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
16999         LDKCommitmentUpdate updates_conv;
17000         updates_conv.inner = (void*)(updates & (~1));
17001         updates_conv.is_owned = (updates & 1) || (updates == 0);
17002         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
17003         updates_conv = CommitmentUpdate_clone(&updates_conv);
17004         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17005         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
17006         uint64_t ret_ref = (uint64_t)ret_copy;
17007         return ret_ref;
17008 }
17009
17010 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
17011         LDKPublicKey node_id_ref;
17012         CHECK(*((uint32_t*)node_id) == 33);
17013         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17014         LDKRevokeAndACK msg_conv;
17015         msg_conv.inner = (void*)(msg & (~1));
17016         msg_conv.is_owned = (msg & 1) || (msg == 0);
17017         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17018         msg_conv = RevokeAndACK_clone(&msg_conv);
17019         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17020         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
17021         uint64_t ret_ref = (uint64_t)ret_copy;
17022         return ret_ref;
17023 }
17024
17025 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
17026         LDKPublicKey node_id_ref;
17027         CHECK(*((uint32_t*)node_id) == 33);
17028         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17029         LDKClosingSigned msg_conv;
17030         msg_conv.inner = (void*)(msg & (~1));
17031         msg_conv.is_owned = (msg & 1) || (msg == 0);
17032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17033         msg_conv = ClosingSigned_clone(&msg_conv);
17034         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17035         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
17036         uint64_t ret_ref = (uint64_t)ret_copy;
17037         return ret_ref;
17038 }
17039
17040 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
17041         LDKPublicKey node_id_ref;
17042         CHECK(*((uint32_t*)node_id) == 33);
17043         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17044         LDKShutdown msg_conv;
17045         msg_conv.inner = (void*)(msg & (~1));
17046         msg_conv.is_owned = (msg & 1) || (msg == 0);
17047         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17048         msg_conv = Shutdown_clone(&msg_conv);
17049         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17050         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
17051         uint64_t ret_ref = (uint64_t)ret_copy;
17052         return ret_ref;
17053 }
17054
17055 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
17056         LDKPublicKey node_id_ref;
17057         CHECK(*((uint32_t*)node_id) == 33);
17058         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17059         LDKChannelReestablish msg_conv;
17060         msg_conv.inner = (void*)(msg & (~1));
17061         msg_conv.is_owned = (msg & 1) || (msg == 0);
17062         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17063         msg_conv = ChannelReestablish_clone(&msg_conv);
17064         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17065         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
17066         uint64_t ret_ref = (uint64_t)ret_copy;
17067         return ret_ref;
17068 }
17069
17070 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
17071         LDKChannelAnnouncement msg_conv;
17072         msg_conv.inner = (void*)(msg & (~1));
17073         msg_conv.is_owned = (msg & 1) || (msg == 0);
17074         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17075         msg_conv = ChannelAnnouncement_clone(&msg_conv);
17076         LDKChannelUpdate update_msg_conv;
17077         update_msg_conv.inner = (void*)(update_msg & (~1));
17078         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
17079         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
17080         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
17081         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17082         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
17083         uint64_t ret_ref = (uint64_t)ret_copy;
17084         return ret_ref;
17085 }
17086
17087 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
17088         LDKNodeAnnouncement msg_conv;
17089         msg_conv.inner = (void*)(msg & (~1));
17090         msg_conv.is_owned = (msg & 1) || (msg == 0);
17091         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17092         msg_conv = NodeAnnouncement_clone(&msg_conv);
17093         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17094         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
17095         uint64_t ret_ref = (uint64_t)ret_copy;
17096         return ret_ref;
17097 }
17098
17099 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
17100         LDKChannelUpdate msg_conv;
17101         msg_conv.inner = (void*)(msg & (~1));
17102         msg_conv.is_owned = (msg & 1) || (msg == 0);
17103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17104         msg_conv = ChannelUpdate_clone(&msg_conv);
17105         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17106         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
17107         uint64_t ret_ref = (uint64_t)ret_copy;
17108         return ret_ref;
17109 }
17110
17111 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
17112         LDKPublicKey node_id_ref;
17113         CHECK(*((uint32_t*)node_id) == 33);
17114         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17115         LDKChannelUpdate msg_conv;
17116         msg_conv.inner = (void*)(msg & (~1));
17117         msg_conv.is_owned = (msg & 1) || (msg == 0);
17118         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17119         msg_conv = ChannelUpdate_clone(&msg_conv);
17120         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17121         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
17122         uint64_t ret_ref = (uint64_t)ret_copy;
17123         return ret_ref;
17124 }
17125
17126 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
17127         LDKPublicKey node_id_ref;
17128         CHECK(*((uint32_t*)node_id) == 33);
17129         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17130         void* action_ptr = (void*)(((uint64_t)action) & ~1);
17131         CHECK_ACCESS(action_ptr);
17132         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
17133         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
17134         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17135         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
17136         uint64_t ret_ref = (uint64_t)ret_copy;
17137         return ret_ref;
17138 }
17139
17140 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
17141         LDKPublicKey node_id_ref;
17142         CHECK(*((uint32_t*)node_id) == 33);
17143         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17144         LDKQueryChannelRange msg_conv;
17145         msg_conv.inner = (void*)(msg & (~1));
17146         msg_conv.is_owned = (msg & 1) || (msg == 0);
17147         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17148         msg_conv = QueryChannelRange_clone(&msg_conv);
17149         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17150         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
17151         uint64_t ret_ref = (uint64_t)ret_copy;
17152         return ret_ref;
17153 }
17154
17155 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
17156         LDKPublicKey node_id_ref;
17157         CHECK(*((uint32_t*)node_id) == 33);
17158         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17159         LDKQueryShortChannelIds msg_conv;
17160         msg_conv.inner = (void*)(msg & (~1));
17161         msg_conv.is_owned = (msg & 1) || (msg == 0);
17162         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17163         msg_conv = QueryShortChannelIds_clone(&msg_conv);
17164         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17165         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
17166         uint64_t ret_ref = (uint64_t)ret_copy;
17167         return ret_ref;
17168 }
17169
17170 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
17171         LDKPublicKey node_id_ref;
17172         CHECK(*((uint32_t*)node_id) == 33);
17173         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
17174         LDKReplyChannelRange msg_conv;
17175         msg_conv.inner = (void*)(msg & (~1));
17176         msg_conv.is_owned = (msg & 1) || (msg == 0);
17177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17178         msg_conv = ReplyChannelRange_clone(&msg_conv);
17179         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17180         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
17181         uint64_t ret_ref = (uint64_t)ret_copy;
17182         return ret_ref;
17183 }
17184
17185 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
17186         if ((this_ptr & 1) != 0) return;
17187         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17188         CHECK_ACCESS(this_ptr_ptr);
17189         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
17190         FREE((void*)this_ptr);
17191         MessageSendEventsProvider_free(this_ptr_conv);
17192 }
17193
17194 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
17195         if ((this_ptr & 1) != 0) return;
17196         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17197         CHECK_ACCESS(this_ptr_ptr);
17198         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
17199         FREE((void*)this_ptr);
17200         EventsProvider_free(this_ptr_conv);
17201 }
17202
17203 void  __attribute__((visibility("default"))) TS_EventHandler_free(uint32_t this_ptr) {
17204         if ((this_ptr & 1) != 0) return;
17205         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17206         CHECK_ACCESS(this_ptr_ptr);
17207         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
17208         FREE((void*)this_ptr);
17209         EventHandler_free(this_ptr_conv);
17210 }
17211
17212 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
17213         if ((this_ptr & 1) != 0) return;
17214         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17215         CHECK_ACCESS(this_ptr_ptr);
17216         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
17217         FREE((void*)this_ptr);
17218         APIError_free(this_ptr_conv);
17219 }
17220
17221 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
17222         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17223         *ret_copy = APIError_clone(arg);
17224 uint64_t ret_ref = (uint64_t)ret_copy;
17225         return ret_ref;
17226 }
17227 int64_t  __attribute__((visibility("default"))) TS_APIError_clone_ptr(uint32_t arg) {
17228         LDKAPIError* arg_conv = (LDKAPIError*)arg;
17229         int64_t ret_val = APIError_clone_ptr(arg_conv);
17230         return ret_val;
17231 }
17232
17233 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
17234         LDKAPIError* orig_conv = (LDKAPIError*)orig;
17235         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17236         *ret_copy = APIError_clone(orig_conv);
17237         uint64_t ret_ref = (uint64_t)ret_copy;
17238         return ret_ref;
17239 }
17240
17241 uint32_t  __attribute__((visibility("default"))) TS_APIError_apimisuse_error(jstring err) {
17242         LDKStr err_conv = str_ref_to_owned_c(err);
17243         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17244         *ret_copy = APIError_apimisuse_error(err_conv);
17245         uint64_t ret_ref = (uint64_t)ret_copy;
17246         return ret_ref;
17247 }
17248
17249 uint32_t  __attribute__((visibility("default"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
17250         LDKStr err_conv = str_ref_to_owned_c(err);
17251         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17252         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
17253         uint64_t ret_ref = (uint64_t)ret_copy;
17254         return ret_ref;
17255 }
17256
17257 uint32_t  __attribute__((visibility("default"))) TS_APIError_route_error(jstring err) {
17258         LDKStr err_conv = str_ref_to_owned_c(err);
17259         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17260         *ret_copy = APIError_route_error(err_conv);
17261         uint64_t ret_ref = (uint64_t)ret_copy;
17262         return ret_ref;
17263 }
17264
17265 uint32_t  __attribute__((visibility("default"))) TS_APIError_channel_unavailable(jstring err) {
17266         LDKStr err_conv = str_ref_to_owned_c(err);
17267         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17268         *ret_copy = APIError_channel_unavailable(err_conv);
17269         uint64_t ret_ref = (uint64_t)ret_copy;
17270         return ret_ref;
17271 }
17272
17273 uint32_t  __attribute__((visibility("default"))) TS_APIError_monitor_update_failed() {
17274         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17275         *ret_copy = APIError_monitor_update_failed();
17276         uint64_t ret_ref = (uint64_t)ret_copy;
17277         return ret_ref;
17278 }
17279
17280 uint32_t  __attribute__((visibility("default"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
17281         LDKShutdownScript script_conv;
17282         script_conv.inner = (void*)(script & (~1));
17283         script_conv.is_owned = (script & 1) || (script == 0);
17284         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
17285         script_conv = ShutdownScript_clone(&script_conv);
17286         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17287         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
17288         uint64_t ret_ref = (uint64_t)ret_copy;
17289         return ret_ref;
17290 }
17291
17292 uint32_t  __attribute__((visibility("default"))) TS_sign(int8_tArray msg, int8_tArray sk) {
17293         LDKu8slice msg_ref;
17294         msg_ref.datalen = *((uint32_t*)msg);
17295         msg_ref.data = (int8_t*)(msg + 4);
17296         unsigned char sk_arr[32];
17297         CHECK(*((uint32_t*)sk) == 32);
17298         memcpy(sk_arr, (uint8_t*)(sk + 4), 32);
17299         unsigned char (*sk_ref)[32] = &sk_arr;
17300         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17301         *ret_conv = sign(msg_ref, sk_ref);
17302         return (uint64_t)ret_conv;
17303 }
17304
17305 uint32_t  __attribute__((visibility("default"))) TS_recover_pk(int8_tArray msg, jstring sig) {
17306         LDKu8slice msg_ref;
17307         msg_ref.datalen = *((uint32_t*)msg);
17308         msg_ref.data = (int8_t*)(msg + 4);
17309         LDKStr sig_conv = str_ref_to_owned_c(sig);
17310         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17311         *ret_conv = recover_pk(msg_ref, sig_conv);
17312         return (uint64_t)ret_conv;
17313 }
17314
17315 jboolean  __attribute__((visibility("default"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
17316         LDKu8slice msg_ref;
17317         msg_ref.datalen = *((uint32_t*)msg);
17318         msg_ref.data = (int8_t*)(msg + 4);
17319         LDKStr sig_conv = str_ref_to_owned_c(sig);
17320         LDKPublicKey pk_ref;
17321         CHECK(*((uint32_t*)pk) == 33);
17322         memcpy(pk_ref.compressed_form, (uint8_t*)(pk + 4), 33);
17323         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
17324         return ret_val;
17325 }
17326
17327 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
17328         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
17329         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
17330         return ret_conv;
17331 }
17332
17333 uint32_t  __attribute__((visibility("default"))) TS_Level_gossip() {
17334         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
17335         return ret_conv;
17336 }
17337
17338 uint32_t  __attribute__((visibility("default"))) TS_Level_trace() {
17339         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
17340         return ret_conv;
17341 }
17342
17343 uint32_t  __attribute__((visibility("default"))) TS_Level_debug() {
17344         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
17345         return ret_conv;
17346 }
17347
17348 uint32_t  __attribute__((visibility("default"))) TS_Level_info() {
17349         uint32_t ret_conv = LDKLevel_to_js(Level_info());
17350         return ret_conv;
17351 }
17352
17353 uint32_t  __attribute__((visibility("default"))) TS_Level_warn() {
17354         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
17355         return ret_conv;
17356 }
17357
17358 uint32_t  __attribute__((visibility("default"))) TS_Level_error() {
17359         uint32_t ret_conv = LDKLevel_to_js(Level_error());
17360         return ret_conv;
17361 }
17362
17363 jboolean  __attribute__((visibility("default"))) TS_Level_eq(uint32_t a, uint32_t b) {
17364         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
17365         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
17366         jboolean ret_val = Level_eq(a_conv, b_conv);
17367         return ret_val;
17368 }
17369
17370 int64_t  __attribute__((visibility("default"))) TS_Level_hash(uint32_t o) {
17371         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
17372         int64_t ret_val = Level_hash(o_conv);
17373         return ret_val;
17374 }
17375
17376 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
17377         uint32_t ret_conv = LDKLevel_to_js(Level_max());
17378         return ret_conv;
17379 }
17380
17381 void  __attribute__((visibility("default"))) TS_Record_free(uint32_t this_obj) {
17382         LDKRecord this_obj_conv;
17383         this_obj_conv.inner = (void*)(this_obj & (~1));
17384         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17386         Record_free(this_obj_conv);
17387 }
17388
17389 uint32_t  __attribute__((visibility("default"))) TS_Record_get_level(uint32_t this_ptr) {
17390         LDKRecord this_ptr_conv;
17391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17392         this_ptr_conv.is_owned = false;
17393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17394         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
17395         return ret_conv;
17396 }
17397
17398 void  __attribute__((visibility("default"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
17399         LDKRecord this_ptr_conv;
17400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17401         this_ptr_conv.is_owned = false;
17402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17403         LDKLevel val_conv = LDKLevel_from_js(val);
17404         Record_set_level(&this_ptr_conv, val_conv);
17405 }
17406
17407 jstring  __attribute__((visibility("default"))) TS_Record_get_args(uint32_t this_ptr) {
17408         LDKRecord this_ptr_conv;
17409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17410         this_ptr_conv.is_owned = false;
17411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17412         LDKStr ret_str = Record_get_args(&this_ptr_conv);
17413         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17414         Str_free(ret_str);
17415         return ret_conv;
17416 }
17417
17418 void  __attribute__((visibility("default"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
17419         LDKRecord this_ptr_conv;
17420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17421         this_ptr_conv.is_owned = false;
17422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17423         LDKStr val_conv = str_ref_to_owned_c(val);
17424         Record_set_args(&this_ptr_conv, val_conv);
17425 }
17426
17427 jstring  __attribute__((visibility("default"))) TS_Record_get_module_path(uint32_t this_ptr) {
17428         LDKRecord this_ptr_conv;
17429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17430         this_ptr_conv.is_owned = false;
17431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17432         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
17433         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17434         Str_free(ret_str);
17435         return ret_conv;
17436 }
17437
17438 void  __attribute__((visibility("default"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
17439         LDKRecord this_ptr_conv;
17440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17441         this_ptr_conv.is_owned = false;
17442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17443         LDKStr val_conv = str_ref_to_owned_c(val);
17444         Record_set_module_path(&this_ptr_conv, val_conv);
17445 }
17446
17447 jstring  __attribute__((visibility("default"))) TS_Record_get_file(uint32_t this_ptr) {
17448         LDKRecord this_ptr_conv;
17449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17450         this_ptr_conv.is_owned = false;
17451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17452         LDKStr ret_str = Record_get_file(&this_ptr_conv);
17453         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17454         Str_free(ret_str);
17455         return ret_conv;
17456 }
17457
17458 void  __attribute__((visibility("default"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
17459         LDKRecord this_ptr_conv;
17460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17461         this_ptr_conv.is_owned = false;
17462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17463         LDKStr val_conv = str_ref_to_owned_c(val);
17464         Record_set_file(&this_ptr_conv, val_conv);
17465 }
17466
17467 int32_t  __attribute__((visibility("default"))) TS_Record_get_line(uint32_t this_ptr) {
17468         LDKRecord this_ptr_conv;
17469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17470         this_ptr_conv.is_owned = false;
17471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17472         int32_t ret_val = Record_get_line(&this_ptr_conv);
17473         return ret_val;
17474 }
17475
17476 void  __attribute__((visibility("default"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
17477         LDKRecord this_ptr_conv;
17478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17479         this_ptr_conv.is_owned = false;
17480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17481         Record_set_line(&this_ptr_conv, val);
17482 }
17483
17484 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
17485         LDKRecord ret_var = Record_clone(arg);
17486 uint64_t ret_ref = 0;
17487 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17488 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17490 ret_ref = (uint64_t)ret_var.inner;
17491 if (ret_var.is_owned) {
17492         ret_ref |= 1;
17493 }
17494         return ret_ref;
17495 }
17496 int64_t  __attribute__((visibility("default"))) TS_Record_clone_ptr(uint32_t arg) {
17497         LDKRecord arg_conv;
17498         arg_conv.inner = (void*)(arg & (~1));
17499         arg_conv.is_owned = false;
17500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17501         int64_t ret_val = Record_clone_ptr(&arg_conv);
17502         return ret_val;
17503 }
17504
17505 uint32_t  __attribute__((visibility("default"))) TS_Record_clone(uint32_t orig) {
17506         LDKRecord orig_conv;
17507         orig_conv.inner = (void*)(orig & (~1));
17508         orig_conv.is_owned = false;
17509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17510         LDKRecord ret_var = Record_clone(&orig_conv);
17511         uint64_t ret_ref = 0;
17512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17513         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17515         ret_ref = (uint64_t)ret_var.inner;
17516         if (ret_var.is_owned) {
17517                 ret_ref |= 1;
17518         }
17519         return ret_ref;
17520 }
17521
17522 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
17523         if ((this_ptr & 1) != 0) return;
17524         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
17525         CHECK_ACCESS(this_ptr_ptr);
17526         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
17527         FREE((void*)this_ptr);
17528         Logger_free(this_ptr_conv);
17529 }
17530
17531 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
17532         LDKChannelHandshakeConfig this_obj_conv;
17533         this_obj_conv.inner = (void*)(this_obj & (~1));
17534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17536         ChannelHandshakeConfig_free(this_obj_conv);
17537 }
17538
17539 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
17540         LDKChannelHandshakeConfig this_ptr_conv;
17541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17542         this_ptr_conv.is_owned = false;
17543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17544         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
17545         return ret_val;
17546 }
17547
17548 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
17549         LDKChannelHandshakeConfig this_ptr_conv;
17550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17551         this_ptr_conv.is_owned = false;
17552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17553         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
17554 }
17555
17556 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
17557         LDKChannelHandshakeConfig this_ptr_conv;
17558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17559         this_ptr_conv.is_owned = false;
17560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17561         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
17562         return ret_val;
17563 }
17564
17565 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
17566         LDKChannelHandshakeConfig this_ptr_conv;
17567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17568         this_ptr_conv.is_owned = false;
17569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17570         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
17571 }
17572
17573 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
17574         LDKChannelHandshakeConfig this_ptr_conv;
17575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17576         this_ptr_conv.is_owned = false;
17577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17578         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
17579         return ret_val;
17580 }
17581
17582 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17583         LDKChannelHandshakeConfig this_ptr_conv;
17584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17585         this_ptr_conv.is_owned = false;
17586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17587         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
17588 }
17589
17590 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
17591         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
17592         uint64_t ret_ref = 0;
17593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17596         ret_ref = (uint64_t)ret_var.inner;
17597         if (ret_var.is_owned) {
17598                 ret_ref |= 1;
17599         }
17600         return ret_ref;
17601 }
17602
17603 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
17604         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
17605 uint64_t ret_ref = 0;
17606 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17607 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17608 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17609 ret_ref = (uint64_t)ret_var.inner;
17610 if (ret_var.is_owned) {
17611         ret_ref |= 1;
17612 }
17613         return ret_ref;
17614 }
17615 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
17616         LDKChannelHandshakeConfig arg_conv;
17617         arg_conv.inner = (void*)(arg & (~1));
17618         arg_conv.is_owned = false;
17619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17620         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
17621         return ret_val;
17622 }
17623
17624 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
17625         LDKChannelHandshakeConfig orig_conv;
17626         orig_conv.inner = (void*)(orig & (~1));
17627         orig_conv.is_owned = false;
17628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17629         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
17630         uint64_t ret_ref = 0;
17631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17634         ret_ref = (uint64_t)ret_var.inner;
17635         if (ret_var.is_owned) {
17636                 ret_ref |= 1;
17637         }
17638         return ret_ref;
17639 }
17640
17641 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
17642         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
17643         uint64_t ret_ref = 0;
17644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17647         ret_ref = (uint64_t)ret_var.inner;
17648         if (ret_var.is_owned) {
17649                 ret_ref |= 1;
17650         }
17651         return ret_ref;
17652 }
17653
17654 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
17655         LDKChannelHandshakeLimits this_obj_conv;
17656         this_obj_conv.inner = (void*)(this_obj & (~1));
17657         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17659         ChannelHandshakeLimits_free(this_obj_conv);
17660 }
17661
17662 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
17663         LDKChannelHandshakeLimits this_ptr_conv;
17664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17665         this_ptr_conv.is_owned = false;
17666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17667         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
17668         return ret_val;
17669 }
17670
17671 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
17672         LDKChannelHandshakeLimits this_ptr_conv;
17673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17674         this_ptr_conv.is_owned = false;
17675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17676         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
17677 }
17678
17679 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
17680         LDKChannelHandshakeLimits this_ptr_conv;
17681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17682         this_ptr_conv.is_owned = false;
17683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17684         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
17685         return ret_val;
17686 }
17687
17688 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
17689         LDKChannelHandshakeLimits this_ptr_conv;
17690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17691         this_ptr_conv.is_owned = false;
17692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17693         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
17694 }
17695
17696 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
17697         LDKChannelHandshakeLimits this_ptr_conv;
17698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17699         this_ptr_conv.is_owned = false;
17700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17701         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
17702         return ret_val;
17703 }
17704
17705 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
17706         LDKChannelHandshakeLimits this_ptr_conv;
17707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17708         this_ptr_conv.is_owned = false;
17709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17710         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17711 }
17712
17713 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
17714         LDKChannelHandshakeLimits this_ptr_conv;
17715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17716         this_ptr_conv.is_owned = false;
17717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17718         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
17719         return ret_val;
17720 }
17721
17722 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
17723         LDKChannelHandshakeLimits this_ptr_conv;
17724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17725         this_ptr_conv.is_owned = false;
17726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17727         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
17728 }
17729
17730 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
17731         LDKChannelHandshakeLimits this_ptr_conv;
17732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17733         this_ptr_conv.is_owned = false;
17734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17735         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
17736         return ret_val;
17737 }
17738
17739 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
17740         LDKChannelHandshakeLimits this_ptr_conv;
17741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17742         this_ptr_conv.is_owned = false;
17743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17744         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
17745 }
17746
17747 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
17748         LDKChannelHandshakeLimits this_ptr_conv;
17749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17750         this_ptr_conv.is_owned = false;
17751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17752         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
17753         return ret_val;
17754 }
17755
17756 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
17757         LDKChannelHandshakeLimits this_ptr_conv;
17758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17759         this_ptr_conv.is_owned = false;
17760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17761         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
17762 }
17763
17764 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
17765         LDKChannelHandshakeLimits this_ptr_conv;
17766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17767         this_ptr_conv.is_owned = false;
17768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17769         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
17770         return ret_val;
17771 }
17772
17773 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
17774         LDKChannelHandshakeLimits this_ptr_conv;
17775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17776         this_ptr_conv.is_owned = false;
17777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17778         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
17779 }
17780
17781 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
17782         LDKChannelHandshakeLimits this_ptr_conv;
17783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17784         this_ptr_conv.is_owned = false;
17785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17786         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
17787         return ret_val;
17788 }
17789
17790 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
17791         LDKChannelHandshakeLimits this_ptr_conv;
17792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17793         this_ptr_conv.is_owned = false;
17794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17795         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
17796 }
17797
17798 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
17799         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
17800         uint64_t ret_ref = 0;
17801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17804         ret_ref = (uint64_t)ret_var.inner;
17805         if (ret_var.is_owned) {
17806                 ret_ref |= 1;
17807         }
17808         return ret_ref;
17809 }
17810
17811 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
17812         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
17813 uint64_t ret_ref = 0;
17814 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17815 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17816 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17817 ret_ref = (uint64_t)ret_var.inner;
17818 if (ret_var.is_owned) {
17819         ret_ref |= 1;
17820 }
17821         return ret_ref;
17822 }
17823 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
17824         LDKChannelHandshakeLimits arg_conv;
17825         arg_conv.inner = (void*)(arg & (~1));
17826         arg_conv.is_owned = false;
17827         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17828         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
17829         return ret_val;
17830 }
17831
17832 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
17833         LDKChannelHandshakeLimits orig_conv;
17834         orig_conv.inner = (void*)(orig & (~1));
17835         orig_conv.is_owned = false;
17836         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17837         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
17838         uint64_t ret_ref = 0;
17839         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17840         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17842         ret_ref = (uint64_t)ret_var.inner;
17843         if (ret_var.is_owned) {
17844                 ret_ref |= 1;
17845         }
17846         return ret_ref;
17847 }
17848
17849 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
17850         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
17851         uint64_t ret_ref = 0;
17852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17855         ret_ref = (uint64_t)ret_var.inner;
17856         if (ret_var.is_owned) {
17857                 ret_ref |= 1;
17858         }
17859         return ret_ref;
17860 }
17861
17862 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_obj) {
17863         LDKChannelConfig this_obj_conv;
17864         this_obj_conv.inner = (void*)(this_obj & (~1));
17865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17867         ChannelConfig_free(this_obj_conv);
17868 }
17869
17870 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
17871         LDKChannelConfig this_ptr_conv;
17872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17873         this_ptr_conv.is_owned = false;
17874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17875         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
17876         return ret_val;
17877 }
17878
17879 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
17880         LDKChannelConfig this_ptr_conv;
17881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17882         this_ptr_conv.is_owned = false;
17883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17884         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
17885 }
17886
17887 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
17888         LDKChannelConfig this_ptr_conv;
17889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17890         this_ptr_conv.is_owned = false;
17891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17892         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
17893         return ret_val;
17894 }
17895
17896 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_forwarding_fee_base_msat(uint32_t this_ptr, int32_t val) {
17897         LDKChannelConfig this_ptr_conv;
17898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17899         this_ptr_conv.is_owned = false;
17900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17901         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
17902 }
17903
17904 int16_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
17905         LDKChannelConfig this_ptr_conv;
17906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17907         this_ptr_conv.is_owned = false;
17908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17909         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
17910         return ret_val;
17911 }
17912
17913 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17914         LDKChannelConfig this_ptr_conv;
17915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17916         this_ptr_conv.is_owned = false;
17917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17918         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
17919 }
17920
17921 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
17922         LDKChannelConfig this_ptr_conv;
17923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17924         this_ptr_conv.is_owned = false;
17925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17926         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
17927         return ret_val;
17928 }
17929
17930 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
17931         LDKChannelConfig this_ptr_conv;
17932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17933         this_ptr_conv.is_owned = false;
17934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17935         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
17936 }
17937
17938 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
17939         LDKChannelConfig this_ptr_conv;
17940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17941         this_ptr_conv.is_owned = false;
17942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17943         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
17944         return ret_val;
17945 }
17946
17947 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
17948         LDKChannelConfig this_ptr_conv;
17949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17950         this_ptr_conv.is_owned = false;
17951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17952         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
17953 }
17954
17955 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_max_dust_htlc_exposure_msat(uint32_t this_ptr) {
17956         LDKChannelConfig this_ptr_conv;
17957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17958         this_ptr_conv.is_owned = false;
17959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17960         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
17961         return ret_val;
17962 }
17963
17964 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_max_dust_htlc_exposure_msat(uint32_t this_ptr, int64_t val) {
17965         LDKChannelConfig this_ptr_conv;
17966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17967         this_ptr_conv.is_owned = false;
17968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17969         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
17970 }
17971
17972 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr) {
17973         LDKChannelConfig this_ptr_conv;
17974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17975         this_ptr_conv.is_owned = false;
17976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17977         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
17978         return ret_val;
17979 }
17980
17981 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_force_close_avoidance_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
17982         LDKChannelConfig this_ptr_conv;
17983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17984         this_ptr_conv.is_owned = false;
17985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17986         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
17987 }
17988
17989 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
17990         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
17991         uint64_t ret_ref = 0;
17992         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17993         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17995         ret_ref = (uint64_t)ret_var.inner;
17996         if (ret_var.is_owned) {
17997                 ret_ref |= 1;
17998         }
17999         return ret_ref;
18000 }
18001
18002 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
18003         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
18004 uint64_t ret_ref = 0;
18005 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18006 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18007 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18008 ret_ref = (uint64_t)ret_var.inner;
18009 if (ret_var.is_owned) {
18010         ret_ref |= 1;
18011 }
18012         return ret_ref;
18013 }
18014 int64_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
18015         LDKChannelConfig arg_conv;
18016         arg_conv.inner = (void*)(arg & (~1));
18017         arg_conv.is_owned = false;
18018         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18019         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
18020         return ret_val;
18021 }
18022
18023 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
18024         LDKChannelConfig orig_conv;
18025         orig_conv.inner = (void*)(orig & (~1));
18026         orig_conv.is_owned = false;
18027         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18028         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
18029         uint64_t ret_ref = 0;
18030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18033         ret_ref = (uint64_t)ret_var.inner;
18034         if (ret_var.is_owned) {
18035                 ret_ref |= 1;
18036         }
18037         return ret_ref;
18038 }
18039
18040 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
18041         LDKChannelConfig ret_var = ChannelConfig_default();
18042         uint64_t ret_ref = 0;
18043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18046         ret_ref = (uint64_t)ret_var.inner;
18047         if (ret_var.is_owned) {
18048                 ret_ref |= 1;
18049         }
18050         return ret_ref;
18051 }
18052
18053 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
18054         LDKChannelConfig obj_conv;
18055         obj_conv.inner = (void*)(obj & (~1));
18056         obj_conv.is_owned = false;
18057         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18058         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
18059         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18060         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18061         CVec_u8Z_free(ret_var);
18062         return ret_arr;
18063 }
18064
18065 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
18066         LDKu8slice ser_ref;
18067         ser_ref.datalen = *((uint32_t*)ser);
18068         ser_ref.data = (int8_t*)(ser + 4);
18069         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
18070         *ret_conv = ChannelConfig_read(ser_ref);
18071         return (uint64_t)ret_conv;
18072 }
18073
18074 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_obj) {
18075         LDKUserConfig this_obj_conv;
18076         this_obj_conv.inner = (void*)(this_obj & (~1));
18077         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18079         UserConfig_free(this_obj_conv);
18080 }
18081
18082 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
18083         LDKUserConfig this_ptr_conv;
18084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18085         this_ptr_conv.is_owned = false;
18086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18087         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
18088         uint64_t ret_ref = 0;
18089         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18090         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18092         ret_ref = (uint64_t)ret_var.inner;
18093         if (ret_var.is_owned) {
18094                 ret_ref |= 1;
18095         }
18096         return ret_ref;
18097 }
18098
18099 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
18100         LDKUserConfig this_ptr_conv;
18101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18102         this_ptr_conv.is_owned = false;
18103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18104         LDKChannelHandshakeConfig val_conv;
18105         val_conv.inner = (void*)(val & (~1));
18106         val_conv.is_owned = (val & 1) || (val == 0);
18107         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18108         val_conv = ChannelHandshakeConfig_clone(&val_conv);
18109         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
18110 }
18111
18112 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
18113         LDKUserConfig this_ptr_conv;
18114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18115         this_ptr_conv.is_owned = false;
18116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18117         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
18118         uint64_t ret_ref = 0;
18119         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18120         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18122         ret_ref = (uint64_t)ret_var.inner;
18123         if (ret_var.is_owned) {
18124                 ret_ref |= 1;
18125         }
18126         return ret_ref;
18127 }
18128
18129 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
18130         LDKUserConfig this_ptr_conv;
18131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18132         this_ptr_conv.is_owned = false;
18133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18134         LDKChannelHandshakeLimits val_conv;
18135         val_conv.inner = (void*)(val & (~1));
18136         val_conv.is_owned = (val & 1) || (val == 0);
18137         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18138         val_conv = ChannelHandshakeLimits_clone(&val_conv);
18139         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
18140 }
18141
18142 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
18143         LDKUserConfig this_ptr_conv;
18144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18145         this_ptr_conv.is_owned = false;
18146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18147         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
18148         uint64_t ret_ref = 0;
18149         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18150         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18152         ret_ref = (uint64_t)ret_var.inner;
18153         if (ret_var.is_owned) {
18154                 ret_ref |= 1;
18155         }
18156         return ret_ref;
18157 }
18158
18159 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
18160         LDKUserConfig this_ptr_conv;
18161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18162         this_ptr_conv.is_owned = false;
18163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18164         LDKChannelConfig val_conv;
18165         val_conv.inner = (void*)(val & (~1));
18166         val_conv.is_owned = (val & 1) || (val == 0);
18167         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18168         val_conv = ChannelConfig_clone(&val_conv);
18169         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
18170 }
18171
18172 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
18173         LDKUserConfig this_ptr_conv;
18174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18175         this_ptr_conv.is_owned = false;
18176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18177         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
18178         return ret_val;
18179 }
18180
18181 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_forwards_to_priv_channels(uint32_t this_ptr, jboolean val) {
18182         LDKUserConfig this_ptr_conv;
18183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18184         this_ptr_conv.is_owned = false;
18185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18186         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
18187 }
18188
18189 jboolean  __attribute__((visibility("default"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
18190         LDKUserConfig this_ptr_conv;
18191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18192         this_ptr_conv.is_owned = false;
18193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18194         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
18195         return ret_val;
18196 }
18197
18198 void  __attribute__((visibility("default"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
18199         LDKUserConfig this_ptr_conv;
18200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18201         this_ptr_conv.is_owned = false;
18202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18203         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
18204 }
18205
18206 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg) {
18207         LDKChannelHandshakeConfig own_channel_config_arg_conv;
18208         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
18209         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
18210         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
18211         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
18212         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
18213         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
18214         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
18215         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
18216         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
18217         LDKChannelConfig channel_options_arg_conv;
18218         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
18219         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
18220         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
18221         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
18222         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg);
18223         uint64_t ret_ref = 0;
18224         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18225         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18227         ret_ref = (uint64_t)ret_var.inner;
18228         if (ret_var.is_owned) {
18229                 ret_ref |= 1;
18230         }
18231         return ret_ref;
18232 }
18233
18234 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
18235         LDKUserConfig ret_var = UserConfig_clone(arg);
18236 uint64_t ret_ref = 0;
18237 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18238 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18239 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18240 ret_ref = (uint64_t)ret_var.inner;
18241 if (ret_var.is_owned) {
18242         ret_ref |= 1;
18243 }
18244         return ret_ref;
18245 }
18246 int64_t  __attribute__((visibility("default"))) TS_UserConfig_clone_ptr(uint32_t arg) {
18247         LDKUserConfig arg_conv;
18248         arg_conv.inner = (void*)(arg & (~1));
18249         arg_conv.is_owned = false;
18250         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18251         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
18252         return ret_val;
18253 }
18254
18255 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
18256         LDKUserConfig orig_conv;
18257         orig_conv.inner = (void*)(orig & (~1));
18258         orig_conv.is_owned = false;
18259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18260         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
18261         uint64_t ret_ref = 0;
18262         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18263         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18265         ret_ref = (uint64_t)ret_var.inner;
18266         if (ret_var.is_owned) {
18267                 ret_ref |= 1;
18268         }
18269         return ret_ref;
18270 }
18271
18272 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
18273         LDKUserConfig ret_var = UserConfig_default();
18274         uint64_t ret_ref = 0;
18275         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18276         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18278         ret_ref = (uint64_t)ret_var.inner;
18279         if (ret_var.is_owned) {
18280                 ret_ref |= 1;
18281         }
18282         return ret_ref;
18283 }
18284
18285 void  __attribute__((visibility("default"))) TS_BestBlock_free(uint32_t this_obj) {
18286         LDKBestBlock this_obj_conv;
18287         this_obj_conv.inner = (void*)(this_obj & (~1));
18288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18290         BestBlock_free(this_obj_conv);
18291 }
18292
18293 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
18294         LDKBestBlock ret_var = BestBlock_clone(arg);
18295 uint64_t ret_ref = 0;
18296 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18297 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18298 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18299 ret_ref = (uint64_t)ret_var.inner;
18300 if (ret_var.is_owned) {
18301         ret_ref |= 1;
18302 }
18303         return ret_ref;
18304 }
18305 int64_t  __attribute__((visibility("default"))) TS_BestBlock_clone_ptr(uint32_t arg) {
18306         LDKBestBlock arg_conv;
18307         arg_conv.inner = (void*)(arg & (~1));
18308         arg_conv.is_owned = false;
18309         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18310         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
18311         return ret_val;
18312 }
18313
18314 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_clone(uint32_t orig) {
18315         LDKBestBlock orig_conv;
18316         orig_conv.inner = (void*)(orig & (~1));
18317         orig_conv.is_owned = false;
18318         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18319         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
18320         uint64_t ret_ref = 0;
18321         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18322         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18324         ret_ref = (uint64_t)ret_var.inner;
18325         if (ret_var.is_owned) {
18326                 ret_ref |= 1;
18327         }
18328         return ret_ref;
18329 }
18330
18331 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_from_genesis(uint32_t network) {
18332         LDKNetwork network_conv = LDKNetwork_from_js(network);
18333         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
18334         uint64_t ret_ref = 0;
18335         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18336         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18338         ret_ref = (uint64_t)ret_var.inner;
18339         if (ret_var.is_owned) {
18340                 ret_ref |= 1;
18341         }
18342         return ret_ref;
18343 }
18344
18345 uint32_t  __attribute__((visibility("default"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
18346         LDKThirtyTwoBytes block_hash_ref;
18347         CHECK(*((uint32_t*)block_hash) == 32);
18348         memcpy(block_hash_ref.data, (uint8_t*)(block_hash + 4), 32);
18349         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
18350         uint64_t ret_ref = 0;
18351         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18352         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18354         ret_ref = (uint64_t)ret_var.inner;
18355         if (ret_var.is_owned) {
18356                 ret_ref |= 1;
18357         }
18358         return ret_ref;
18359 }
18360
18361 int8_tArray  __attribute__((visibility("default"))) TS_BestBlock_block_hash(uint32_t this_arg) {
18362         LDKBestBlock this_arg_conv;
18363         this_arg_conv.inner = (void*)(this_arg & (~1));
18364         this_arg_conv.is_owned = false;
18365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18366         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18367         memcpy((uint8_t*)(ret_arr + 4), BestBlock_block_hash(&this_arg_conv).data, 32);
18368         return ret_arr;
18369 }
18370
18371 int32_t  __attribute__((visibility("default"))) TS_BestBlock_height(uint32_t this_arg) {
18372         LDKBestBlock this_arg_conv;
18373         this_arg_conv.inner = (void*)(this_arg & (~1));
18374         this_arg_conv.is_owned = false;
18375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18376         int32_t ret_val = BestBlock_height(&this_arg_conv);
18377         return ret_val;
18378 }
18379
18380 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
18381         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
18382         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
18383         return ret_conv;
18384 }
18385
18386 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_chain() {
18387         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
18388         return ret_conv;
18389 }
18390
18391 uint32_t  __attribute__((visibility("default"))) TS_AccessError_unknown_tx() {
18392         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
18393         return ret_conv;
18394 }
18395
18396 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
18397         if ((this_ptr & 1) != 0) return;
18398         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18399         CHECK_ACCESS(this_ptr_ptr);
18400         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
18401         FREE((void*)this_ptr);
18402         Access_free(this_ptr_conv);
18403 }
18404
18405 void  __attribute__((visibility("default"))) TS_Listen_free(uint32_t this_ptr) {
18406         if ((this_ptr & 1) != 0) return;
18407         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18408         CHECK_ACCESS(this_ptr_ptr);
18409         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
18410         FREE((void*)this_ptr);
18411         Listen_free(this_ptr_conv);
18412 }
18413
18414 void  __attribute__((visibility("default"))) TS_Confirm_free(uint32_t this_ptr) {
18415         if ((this_ptr & 1) != 0) return;
18416         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18417         CHECK_ACCESS(this_ptr_ptr);
18418         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
18419         FREE((void*)this_ptr);
18420         Confirm_free(this_ptr_conv);
18421 }
18422
18423 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
18424         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
18425         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
18426         return ret_conv;
18427 }
18428
18429 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
18430         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
18431         return ret_conv;
18432 }
18433
18434 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
18435         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
18436         return ret_conv;
18437 }
18438
18439 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
18440         if ((this_ptr & 1) != 0) return;
18441         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18442         CHECK_ACCESS(this_ptr_ptr);
18443         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
18444         FREE((void*)this_ptr);
18445         Watch_free(this_ptr_conv);
18446 }
18447
18448 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
18449         if ((this_ptr & 1) != 0) return;
18450         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18451         CHECK_ACCESS(this_ptr_ptr);
18452         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
18453         FREE((void*)this_ptr);
18454         Filter_free(this_ptr_conv);
18455 }
18456
18457 void  __attribute__((visibility("default"))) TS_WatchedOutput_free(uint32_t this_obj) {
18458         LDKWatchedOutput this_obj_conv;
18459         this_obj_conv.inner = (void*)(this_obj & (~1));
18460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18462         WatchedOutput_free(this_obj_conv);
18463 }
18464
18465 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
18466         LDKWatchedOutput this_ptr_conv;
18467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18468         this_ptr_conv.is_owned = false;
18469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18470         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
18471         memcpy((uint8_t*)(ret_arr + 4), WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
18472         return ret_arr;
18473 }
18474
18475 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
18476         LDKWatchedOutput this_ptr_conv;
18477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18478         this_ptr_conv.is_owned = false;
18479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18480         LDKThirtyTwoBytes val_ref;
18481         CHECK(*((uint32_t*)val) == 32);
18482         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
18483         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
18484 }
18485
18486 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
18487         LDKWatchedOutput this_ptr_conv;
18488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18489         this_ptr_conv.is_owned = false;
18490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18491         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
18492         uint64_t ret_ref = 0;
18493         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18494         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18496         ret_ref = (uint64_t)ret_var.inner;
18497         if (ret_var.is_owned) {
18498                 ret_ref |= 1;
18499         }
18500         return ret_ref;
18501 }
18502
18503 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
18504         LDKWatchedOutput this_ptr_conv;
18505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18506         this_ptr_conv.is_owned = false;
18507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18508         LDKOutPoint val_conv;
18509         val_conv.inner = (void*)(val & (~1));
18510         val_conv.is_owned = (val & 1) || (val == 0);
18511         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18512         val_conv = OutPoint_clone(&val_conv);
18513         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
18514 }
18515
18516 int8_tArray  __attribute__((visibility("default"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
18517         LDKWatchedOutput this_ptr_conv;
18518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18519         this_ptr_conv.is_owned = false;
18520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18521         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
18522         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18523         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18524         return ret_arr;
18525 }
18526
18527 void  __attribute__((visibility("default"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
18528         LDKWatchedOutput this_ptr_conv;
18529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18530         this_ptr_conv.is_owned = false;
18531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18532         LDKCVec_u8Z val_ref;
18533         val_ref.datalen = *((uint32_t*)val);
18534         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18535         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
18536         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
18537 }
18538
18539 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_new(int8_tArray block_hash_arg, uint32_t outpoint_arg, int8_tArray script_pubkey_arg) {
18540         LDKThirtyTwoBytes block_hash_arg_ref;
18541         CHECK(*((uint32_t*)block_hash_arg) == 32);
18542         memcpy(block_hash_arg_ref.data, (uint8_t*)(block_hash_arg + 4), 32);
18543         LDKOutPoint outpoint_arg_conv;
18544         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18545         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18546         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
18547         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18548         LDKCVec_u8Z script_pubkey_arg_ref;
18549         script_pubkey_arg_ref.datalen = *((uint32_t*)script_pubkey_arg);
18550         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18551         memcpy(script_pubkey_arg_ref.data, (uint8_t*)(script_pubkey_arg + 4), script_pubkey_arg_ref.datalen);
18552         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
18553         uint64_t ret_ref = 0;
18554         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18555         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18557         ret_ref = (uint64_t)ret_var.inner;
18558         if (ret_var.is_owned) {
18559                 ret_ref |= 1;
18560         }
18561         return ret_ref;
18562 }
18563
18564 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
18565         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
18566 uint64_t ret_ref = 0;
18567 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18568 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18569 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18570 ret_ref = (uint64_t)ret_var.inner;
18571 if (ret_var.is_owned) {
18572         ret_ref |= 1;
18573 }
18574         return ret_ref;
18575 }
18576 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
18577         LDKWatchedOutput arg_conv;
18578         arg_conv.inner = (void*)(arg & (~1));
18579         arg_conv.is_owned = false;
18580         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18581         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
18582         return ret_val;
18583 }
18584
18585 uint32_t  __attribute__((visibility("default"))) TS_WatchedOutput_clone(uint32_t orig) {
18586         LDKWatchedOutput orig_conv;
18587         orig_conv.inner = (void*)(orig & (~1));
18588         orig_conv.is_owned = false;
18589         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18590         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
18591         uint64_t ret_ref = 0;
18592         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18593         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18595         ret_ref = (uint64_t)ret_var.inner;
18596         if (ret_var.is_owned) {
18597                 ret_ref |= 1;
18598         }
18599         return ret_ref;
18600 }
18601
18602 int64_t  __attribute__((visibility("default"))) TS_WatchedOutput_hash(uint32_t o) {
18603         LDKWatchedOutput o_conv;
18604         o_conv.inner = (void*)(o & (~1));
18605         o_conv.is_owned = false;
18606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18607         int64_t ret_val = WatchedOutput_hash(&o_conv);
18608         return ret_val;
18609 }
18610
18611 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
18612         if ((this_ptr & 1) != 0) return;
18613         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18614         CHECK_ACCESS(this_ptr_ptr);
18615         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
18616         FREE((void*)this_ptr);
18617         BroadcasterInterface_free(this_ptr_conv);
18618 }
18619
18620 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
18621         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
18622         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
18623         return ret_conv;
18624 }
18625
18626 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_background() {
18627         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
18628         return ret_conv;
18629 }
18630
18631 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_normal() {
18632         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
18633         return ret_conv;
18634 }
18635
18636 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_high_priority() {
18637         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
18638         return ret_conv;
18639 }
18640
18641 jboolean  __attribute__((visibility("default"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
18642         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
18643         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
18644         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
18645         return ret_val;
18646 }
18647
18648 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
18649         if ((this_ptr & 1) != 0) return;
18650         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18651         CHECK_ACCESS(this_ptr_ptr);
18652         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
18653         FREE((void*)this_ptr);
18654         FeeEstimator_free(this_ptr_conv);
18655 }
18656
18657 void  __attribute__((visibility("default"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
18658         LDKMonitorUpdateId this_obj_conv;
18659         this_obj_conv.inner = (void*)(this_obj & (~1));
18660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18662         MonitorUpdateId_free(this_obj_conv);
18663 }
18664
18665 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
18666         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
18667 uint64_t ret_ref = 0;
18668 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18669 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18670 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18671 ret_ref = (uint64_t)ret_var.inner;
18672 if (ret_var.is_owned) {
18673         ret_ref |= 1;
18674 }
18675         return ret_ref;
18676 }
18677 int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
18678         LDKMonitorUpdateId arg_conv;
18679         arg_conv.inner = (void*)(arg & (~1));
18680         arg_conv.is_owned = false;
18681         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18682         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
18683         return ret_val;
18684 }
18685
18686 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_clone(uint32_t orig) {
18687         LDKMonitorUpdateId orig_conv;
18688         orig_conv.inner = (void*)(orig & (~1));
18689         orig_conv.is_owned = false;
18690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18691         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
18692         uint64_t ret_ref = 0;
18693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18696         ret_ref = (uint64_t)ret_var.inner;
18697         if (ret_var.is_owned) {
18698                 ret_ref |= 1;
18699         }
18700         return ret_ref;
18701 }
18702
18703 int64_t  __attribute__((visibility("default"))) TS_MonitorUpdateId_hash(uint32_t o) {
18704         LDKMonitorUpdateId o_conv;
18705         o_conv.inner = (void*)(o & (~1));
18706         o_conv.is_owned = false;
18707         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18708         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
18709         return ret_val;
18710 }
18711
18712 jboolean  __attribute__((visibility("default"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
18713         LDKMonitorUpdateId a_conv;
18714         a_conv.inner = (void*)(a & (~1));
18715         a_conv.is_owned = false;
18716         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18717         LDKMonitorUpdateId b_conv;
18718         b_conv.inner = (void*)(b & (~1));
18719         b_conv.is_owned = false;
18720         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18721         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
18722         return ret_val;
18723 }
18724
18725 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
18726         if ((this_ptr & 1) != 0) return;
18727         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
18728         CHECK_ACCESS(this_ptr_ptr);
18729         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
18730         FREE((void*)this_ptr);
18731         Persist_free(this_ptr_conv);
18732 }
18733
18734 void  __attribute__((visibility("default"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
18735         LDKLockedChannelMonitor this_obj_conv;
18736         this_obj_conv.inner = (void*)(this_obj & (~1));
18737         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18739         LockedChannelMonitor_free(this_obj_conv);
18740 }
18741
18742 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_obj) {
18743         LDKChainMonitor this_obj_conv;
18744         this_obj_conv.inner = (void*)(this_obj & (~1));
18745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18747         ChainMonitor_free(this_obj_conv);
18748 }
18749
18750 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
18751         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
18752         CHECK_ACCESS(chain_source_ptr);
18753         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
18754         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
18755         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
18756                 // Manually implement clone for Java trait instances
18757         }
18758         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
18759         CHECK_ACCESS(broadcaster_ptr);
18760         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18761         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
18762         CHECK_ACCESS(logger_ptr);
18763         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18764         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
18765         CHECK_ACCESS(feeest_ptr);
18766         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
18767         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
18768         CHECK_ACCESS(persister_ptr);
18769         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
18770         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
18771         uint64_t ret_ref = 0;
18772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18775         ret_ref = (uint64_t)ret_var.inner;
18776         if (ret_var.is_owned) {
18777                 ret_ref |= 1;
18778         }
18779         return ret_ref;
18780 }
18781
18782 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
18783         LDKChainMonitor this_arg_conv;
18784         this_arg_conv.inner = (void*)(this_arg & (~1));
18785         this_arg_conv.is_owned = false;
18786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18787         LDKCVec_ChannelDetailsZ ignored_channels_constr;
18788         ignored_channels_constr.datalen = *((uint32_t*)ignored_channels);
18789         if (ignored_channels_constr.datalen > 0)
18790                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18791         else
18792                 ignored_channels_constr.data = NULL;
18793         uint32_t* ignored_channels_vals = (uint32_t*)(ignored_channels + 4);
18794         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
18795                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
18796                 LDKChannelDetails ignored_channels_conv_16_conv;
18797                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
18798                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
18799                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
18800                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
18801                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
18802         }
18803         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
18804         uint32_tArray ret_arr = NULL;
18805         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18806         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18807         for (size_t j = 0; j < ret_var.datalen; j++) {
18808                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18809                 *ret_conv_9_copy = ret_var.data[j];
18810                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
18811                 ret_arr_ptr[j] = ret_conv_9_ref;
18812         }
18813         
18814         FREE(ret_var.data);
18815         return ret_arr;
18816 }
18817
18818 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
18819         LDKChainMonitor this_arg_conv;
18820         this_arg_conv.inner = (void*)(this_arg & (~1));
18821         this_arg_conv.is_owned = false;
18822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18823         LDKOutPoint funding_txo_conv;
18824         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18825         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18826         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18827         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18828         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
18829         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
18830         return (uint64_t)ret_conv;
18831 }
18832
18833 uint32_tArray  __attribute__((visibility("default"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
18834         LDKChainMonitor this_arg_conv;
18835         this_arg_conv.inner = (void*)(this_arg & (~1));
18836         this_arg_conv.is_owned = false;
18837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18838         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
18839         uint32_tArray ret_arr = NULL;
18840         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
18841         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
18842         for (size_t k = 0; k < ret_var.datalen; k++) {
18843                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
18844                 uint64_t ret_conv_10_ref = 0;
18845                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18846                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18847                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
18848                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
18849                 if (ret_conv_10_var.is_owned) {
18850                         ret_conv_10_ref |= 1;
18851                 }
18852                 ret_arr_ptr[k] = ret_conv_10_ref;
18853         }
18854         
18855         FREE(ret_var.data);
18856         return ret_arr;
18857 }
18858
18859 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, uint32_t completed_update_id) {
18860         LDKChainMonitor this_arg_conv;
18861         this_arg_conv.inner = (void*)(this_arg & (~1));
18862         this_arg_conv.is_owned = false;
18863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18864         LDKOutPoint funding_txo_conv;
18865         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18866         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18867         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18868         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18869         LDKMonitorUpdateId completed_update_id_conv;
18870         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
18871         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
18872         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
18873         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
18874         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18875         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
18876         return (uint64_t)ret_conv;
18877 }
18878
18879 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
18880         LDKChainMonitor this_arg_conv;
18881         this_arg_conv.inner = (void*)(this_arg & (~1));
18882         this_arg_conv.is_owned = false;
18883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18884         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18885         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
18886         return (uint64_t)ret_ret;
18887 }
18888
18889 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
18890         LDKChainMonitor this_arg_conv;
18891         this_arg_conv.inner = (void*)(this_arg & (~1));
18892         this_arg_conv.is_owned = false;
18893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18894         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18895         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
18896         return (uint64_t)ret_ret;
18897 }
18898
18899 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
18900         LDKChainMonitor this_arg_conv;
18901         this_arg_conv.inner = (void*)(this_arg & (~1));
18902         this_arg_conv.is_owned = false;
18903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18904         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
18905         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
18906         return (uint64_t)ret_ret;
18907 }
18908
18909 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
18910         LDKChainMonitor this_arg_conv;
18911         this_arg_conv.inner = (void*)(this_arg & (~1));
18912         this_arg_conv.is_owned = false;
18913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18914         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18915         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
18916         return (uint64_t)ret_ret;
18917 }
18918
18919 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
18920         LDKChannelMonitorUpdate this_obj_conv;
18921         this_obj_conv.inner = (void*)(this_obj & (~1));
18922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18924         ChannelMonitorUpdate_free(this_obj_conv);
18925 }
18926
18927 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
18928         LDKChannelMonitorUpdate this_ptr_conv;
18929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18930         this_ptr_conv.is_owned = false;
18931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18932         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
18933         return ret_val;
18934 }
18935
18936 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
18937         LDKChannelMonitorUpdate this_ptr_conv;
18938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18939         this_ptr_conv.is_owned = false;
18940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18941         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
18942 }
18943
18944 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
18945         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
18946 uint64_t ret_ref = 0;
18947 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18948 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18949 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18950 ret_ref = (uint64_t)ret_var.inner;
18951 if (ret_var.is_owned) {
18952         ret_ref |= 1;
18953 }
18954         return ret_ref;
18955 }
18956 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
18957         LDKChannelMonitorUpdate arg_conv;
18958         arg_conv.inner = (void*)(arg & (~1));
18959         arg_conv.is_owned = false;
18960         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18961         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
18962         return ret_val;
18963 }
18964
18965 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
18966         LDKChannelMonitorUpdate orig_conv;
18967         orig_conv.inner = (void*)(orig & (~1));
18968         orig_conv.is_owned = false;
18969         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18970         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
18971         uint64_t ret_ref = 0;
18972         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18973         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18975         ret_ref = (uint64_t)ret_var.inner;
18976         if (ret_var.is_owned) {
18977                 ret_ref |= 1;
18978         }
18979         return ret_ref;
18980 }
18981
18982 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
18983         LDKChannelMonitorUpdate obj_conv;
18984         obj_conv.inner = (void*)(obj & (~1));
18985         obj_conv.is_owned = false;
18986         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18987         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
18988         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
18989         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
18990         CVec_u8Z_free(ret_var);
18991         return ret_arr;
18992 }
18993
18994 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
18995         LDKu8slice ser_ref;
18996         ser_ref.datalen = *((uint32_t*)ser);
18997         ser_ref.data = (int8_t*)(ser + 4);
18998         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18999         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
19000         return (uint64_t)ret_conv;
19001 }
19002
19003 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
19004         if ((this_ptr & 1) != 0) return;
19005         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19006         CHECK_ACCESS(this_ptr_ptr);
19007         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
19008         FREE((void*)this_ptr);
19009         MonitorEvent_free(this_ptr_conv);
19010 }
19011
19012 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
19013         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19014         *ret_copy = MonitorEvent_clone(arg);
19015 uint64_t ret_ref = (uint64_t)ret_copy;
19016         return ret_ref;
19017 }
19018 int64_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
19019         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
19020         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
19021         return ret_val;
19022 }
19023
19024 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
19025         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
19026         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19027         *ret_copy = MonitorEvent_clone(orig_conv);
19028         uint64_t ret_ref = (uint64_t)ret_copy;
19029         return ret_ref;
19030 }
19031
19032 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_htlcevent(uint32_t a) {
19033         LDKHTLCUpdate a_conv;
19034         a_conv.inner = (void*)(a & (~1));
19035         a_conv.is_owned = (a & 1) || (a == 0);
19036         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19037         a_conv = HTLCUpdate_clone(&a_conv);
19038         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19039         *ret_copy = MonitorEvent_htlcevent(a_conv);
19040         uint64_t ret_ref = (uint64_t)ret_copy;
19041         return ret_ref;
19042 }
19043
19044 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
19045         LDKOutPoint a_conv;
19046         a_conv.inner = (void*)(a & (~1));
19047         a_conv.is_owned = (a & 1) || (a == 0);
19048         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19049         a_conv = OutPoint_clone(&a_conv);
19050         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19051         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
19052         uint64_t ret_ref = (uint64_t)ret_copy;
19053         return ret_ref;
19054 }
19055
19056 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
19057         LDKOutPoint funding_txo_conv;
19058         funding_txo_conv.inner = (void*)(funding_txo & (~1));
19059         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
19060         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
19061         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
19062         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19063         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
19064         uint64_t ret_ref = (uint64_t)ret_copy;
19065         return ret_ref;
19066 }
19067
19068 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_update_failed(uint32_t a) {
19069         LDKOutPoint a_conv;
19070         a_conv.inner = (void*)(a & (~1));
19071         a_conv.is_owned = (a & 1) || (a == 0);
19072         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19073         a_conv = OutPoint_clone(&a_conv);
19074         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19075         *ret_copy = MonitorEvent_update_failed(a_conv);
19076         uint64_t ret_ref = (uint64_t)ret_copy;
19077         return ret_ref;
19078 }
19079
19080 int8_tArray  __attribute__((visibility("default"))) TS_MonitorEvent_write(uint32_t obj) {
19081         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
19082         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
19083         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19084         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19085         CVec_u8Z_free(ret_var);
19086         return ret_arr;
19087 }
19088
19089 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_read(int8_tArray ser) {
19090         LDKu8slice ser_ref;
19091         ser_ref.datalen = *((uint32_t*)ser);
19092         ser_ref.data = (int8_t*)(ser + 4);
19093         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
19094         *ret_conv = MonitorEvent_read(ser_ref);
19095         return (uint64_t)ret_conv;
19096 }
19097
19098 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_obj) {
19099         LDKHTLCUpdate this_obj_conv;
19100         this_obj_conv.inner = (void*)(this_obj & (~1));
19101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19103         HTLCUpdate_free(this_obj_conv);
19104 }
19105
19106 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
19107         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
19108 uint64_t ret_ref = 0;
19109 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19110 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19111 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19112 ret_ref = (uint64_t)ret_var.inner;
19113 if (ret_var.is_owned) {
19114         ret_ref |= 1;
19115 }
19116         return ret_ref;
19117 }
19118 int64_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
19119         LDKHTLCUpdate arg_conv;
19120         arg_conv.inner = (void*)(arg & (~1));
19121         arg_conv.is_owned = false;
19122         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19123         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
19124         return ret_val;
19125 }
19126
19127 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
19128         LDKHTLCUpdate orig_conv;
19129         orig_conv.inner = (void*)(orig & (~1));
19130         orig_conv.is_owned = false;
19131         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19132         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
19133         uint64_t ret_ref = 0;
19134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19137         ret_ref = (uint64_t)ret_var.inner;
19138         if (ret_var.is_owned) {
19139                 ret_ref |= 1;
19140         }
19141         return ret_ref;
19142 }
19143
19144 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
19145         LDKHTLCUpdate obj_conv;
19146         obj_conv.inner = (void*)(obj & (~1));
19147         obj_conv.is_owned = false;
19148         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19149         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
19150         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19151         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19152         CVec_u8Z_free(ret_var);
19153         return ret_arr;
19154 }
19155
19156 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
19157         LDKu8slice ser_ref;
19158         ser_ref.datalen = *((uint32_t*)ser);
19159         ser_ref.data = (int8_t*)(ser + 4);
19160         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19161         *ret_conv = HTLCUpdate_read(ser_ref);
19162         return (uint64_t)ret_conv;
19163 }
19164
19165 void  __attribute__((visibility("default"))) TS_Balance_free(uint32_t this_ptr) {
19166         if ((this_ptr & 1) != 0) return;
19167         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19168         CHECK_ACCESS(this_ptr_ptr);
19169         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
19170         FREE((void*)this_ptr);
19171         Balance_free(this_ptr_conv);
19172 }
19173
19174 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
19175         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19176         *ret_copy = Balance_clone(arg);
19177 uint64_t ret_ref = (uint64_t)ret_copy;
19178         return ret_ref;
19179 }
19180 int64_t  __attribute__((visibility("default"))) TS_Balance_clone_ptr(uint32_t arg) {
19181         LDKBalance* arg_conv = (LDKBalance*)arg;
19182         int64_t ret_val = Balance_clone_ptr(arg_conv);
19183         return ret_val;
19184 }
19185
19186 uint32_t  __attribute__((visibility("default"))) TS_Balance_clone(uint32_t orig) {
19187         LDKBalance* orig_conv = (LDKBalance*)orig;
19188         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19189         *ret_copy = Balance_clone(orig_conv);
19190         uint64_t ret_ref = (uint64_t)ret_copy;
19191         return ret_ref;
19192 }
19193
19194 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
19195         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19196         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
19197         uint64_t ret_ref = (uint64_t)ret_copy;
19198         return ret_ref;
19199 }
19200
19201 uint32_t  __attribute__((visibility("default"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
19202         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19203         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
19204         uint64_t ret_ref = (uint64_t)ret_copy;
19205         return ret_ref;
19206 }
19207
19208 uint32_t  __attribute__((visibility("default"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
19209         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19210         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
19211         uint64_t ret_ref = (uint64_t)ret_copy;
19212         return ret_ref;
19213 }
19214
19215 uint32_t  __attribute__((visibility("default"))) TS_Balance_maybe_claimable_htlcawaiting_timeout(int64_t claimable_amount_satoshis, int32_t claimable_height) {
19216         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19217         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
19218         uint64_t ret_ref = (uint64_t)ret_copy;
19219         return ret_ref;
19220 }
19221
19222 jboolean  __attribute__((visibility("default"))) TS_Balance_eq(uint32_t a, uint32_t b) {
19223         LDKBalance* a_conv = (LDKBalance*)a;
19224         LDKBalance* b_conv = (LDKBalance*)b;
19225         jboolean ret_val = Balance_eq(a_conv, b_conv);
19226         return ret_val;
19227 }
19228
19229 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_obj) {
19230         LDKChannelMonitor this_obj_conv;
19231         this_obj_conv.inner = (void*)(this_obj & (~1));
19232         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19234         ChannelMonitor_free(this_obj_conv);
19235 }
19236
19237 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
19238         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
19239 uint64_t ret_ref = 0;
19240 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19241 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19242 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19243 ret_ref = (uint64_t)ret_var.inner;
19244 if (ret_var.is_owned) {
19245         ret_ref |= 1;
19246 }
19247         return ret_ref;
19248 }
19249 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
19250         LDKChannelMonitor arg_conv;
19251         arg_conv.inner = (void*)(arg & (~1));
19252         arg_conv.is_owned = false;
19253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19254         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
19255         return ret_val;
19256 }
19257
19258 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
19259         LDKChannelMonitor orig_conv;
19260         orig_conv.inner = (void*)(orig & (~1));
19261         orig_conv.is_owned = false;
19262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19263         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
19264         uint64_t ret_ref = 0;
19265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19268         ret_ref = (uint64_t)ret_var.inner;
19269         if (ret_var.is_owned) {
19270                 ret_ref |= 1;
19271         }
19272         return ret_ref;
19273 }
19274
19275 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
19276         LDKChannelMonitor obj_conv;
19277         obj_conv.inner = (void*)(obj & (~1));
19278         obj_conv.is_owned = false;
19279         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19280         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
19281         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19282         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19283         CVec_u8Z_free(ret_var);
19284         return ret_arr;
19285 }
19286
19287 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_update_monitor(uint32_t this_arg, uint32_t updates, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19288         LDKChannelMonitor this_arg_conv;
19289         this_arg_conv.inner = (void*)(this_arg & (~1));
19290         this_arg_conv.is_owned = false;
19291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19292         LDKChannelMonitorUpdate updates_conv;
19293         updates_conv.inner = (void*)(updates & (~1));
19294         updates_conv.is_owned = false;
19295         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19296         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19297         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
19298         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
19299         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19300         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
19301         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
19302         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19303         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19304         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19305         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
19306         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
19307         return (uint64_t)ret_conv;
19308 }
19309
19310 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
19311         LDKChannelMonitor this_arg_conv;
19312         this_arg_conv.inner = (void*)(this_arg & (~1));
19313         this_arg_conv.is_owned = false;
19314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19315         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
19316         return ret_val;
19317 }
19318
19319 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
19320         LDKChannelMonitor this_arg_conv;
19321         this_arg_conv.inner = (void*)(this_arg & (~1));
19322         this_arg_conv.is_owned = false;
19323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19324         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19325         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
19326         return ((uint64_t)ret_conv);
19327 }
19328
19329 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
19330         LDKChannelMonitor this_arg_conv;
19331         this_arg_conv.inner = (void*)(this_arg & (~1));
19332         this_arg_conv.is_owned = false;
19333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19334         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
19335         uint32_tArray ret_arr = NULL;
19336         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19337         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19338         for (size_t o = 0; o < ret_var.datalen; o++) {
19339                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19340                 *ret_conv_40_conv = ret_var.data[o];
19341                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
19342         }
19343         
19344         FREE(ret_var.data);
19345         return ret_arr;
19346 }
19347
19348 void  __attribute__((visibility("default"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
19349         LDKChannelMonitor this_arg_conv;
19350         this_arg_conv.inner = (void*)(this_arg & (~1));
19351         this_arg_conv.is_owned = false;
19352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19353         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
19354         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
19355         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
19356         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
19357 }
19358
19359 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
19360         LDKChannelMonitor this_arg_conv;
19361         this_arg_conv.inner = (void*)(this_arg & (~1));
19362         this_arg_conv.is_owned = false;
19363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19364         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
19365         uint32_tArray ret_arr = NULL;
19366         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19367         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19368         for (size_t o = 0; o < ret_var.datalen; o++) {
19369                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19370                 *ret_conv_14_copy = ret_var.data[o];
19371                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
19372                 ret_arr_ptr[o] = ret_conv_14_ref;
19373         }
19374         
19375         FREE(ret_var.data);
19376         return ret_arr;
19377 }
19378
19379 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
19380         LDKChannelMonitor this_arg_conv;
19381         this_arg_conv.inner = (void*)(this_arg & (~1));
19382         this_arg_conv.is_owned = false;
19383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19384         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
19385         uint32_tArray ret_arr = NULL;
19386         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19387         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19388         for (size_t h = 0; h < ret_var.datalen; h++) {
19389                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19390                 *ret_conv_7_copy = ret_var.data[h];
19391                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
19392                 ret_arr_ptr[h] = ret_conv_7_ref;
19393         }
19394         
19395         FREE(ret_var.data);
19396         return ret_arr;
19397 }
19398
19399 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
19400         LDKChannelMonitor this_arg_conv;
19401         this_arg_conv.inner = (void*)(this_arg & (~1));
19402         this_arg_conv.is_owned = false;
19403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19404         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19405         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19406         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19407         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
19408         ptrArray ret_arr = NULL;
19409         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
19410         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
19411         for (size_t m = 0; m < ret_var.datalen; m++) {
19412                 LDKTransaction ret_conv_12_var = ret_var.data[m];
19413                 int8_tArray ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19414                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_conv_12_var.data, ret_conv_12_var.datalen);
19415                 Transaction_free(ret_conv_12_var);
19416                 ret_arr_ptr[m] = ret_conv_12_arr;
19417         }
19418         
19419         FREE(ret_var.data);
19420         return ret_arr;
19421 }
19422
19423 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19424         LDKChannelMonitor this_arg_conv;
19425         this_arg_conv.inner = (void*)(this_arg & (~1));
19426         this_arg_conv.is_owned = false;
19427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19428         unsigned char header_arr[80];
19429         CHECK(*((uint32_t*)header) == 80);
19430         memcpy(header_arr, (uint8_t*)(header + 4), 80);
19431         unsigned char (*header_ref)[80] = &header_arr;
19432         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19433         txdata_constr.datalen = *((uint32_t*)txdata);
19434         if (txdata_constr.datalen > 0)
19435                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19436         else
19437                 txdata_constr.data = NULL;
19438         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
19439         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19440                 uint32_t txdata_conv_28 = txdata_vals[c];
19441                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19442                 CHECK_ACCESS(txdata_conv_28_ptr);
19443                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19444                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19445                 txdata_constr.data[c] = txdata_conv_28_conv;
19446         }
19447         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19448         CHECK_ACCESS(broadcaster_ptr);
19449         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19450         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19451         CHECK_ACCESS(fee_estimator_ptr);
19452         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19453         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19454         CHECK_ACCESS(logger_ptr);
19455         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19456         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19457         uint32_tArray ret_arr = NULL;
19458         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19459         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19460         for (size_t n = 0; n < ret_var.datalen; n++) {
19461                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19462                 *ret_conv_39_conv = ret_var.data[n];
19463                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19464         }
19465         
19466         FREE(ret_var.data);
19467         return ret_arr;
19468 }
19469
19470 void  __attribute__((visibility("default"))) TS_ChannelMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19471         LDKChannelMonitor this_arg_conv;
19472         this_arg_conv.inner = (void*)(this_arg & (~1));
19473         this_arg_conv.is_owned = false;
19474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19475         unsigned char header_arr[80];
19476         CHECK(*((uint32_t*)header) == 80);
19477         memcpy(header_arr, (uint8_t*)(header + 4), 80);
19478         unsigned char (*header_ref)[80] = &header_arr;
19479         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19480         CHECK_ACCESS(broadcaster_ptr);
19481         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19482         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19483         CHECK_ACCESS(fee_estimator_ptr);
19484         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19485         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19486         CHECK_ACCESS(logger_ptr);
19487         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19488         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19489 }
19490
19491 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_transactions_confirmed(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19492         LDKChannelMonitor this_arg_conv;
19493         this_arg_conv.inner = (void*)(this_arg & (~1));
19494         this_arg_conv.is_owned = false;
19495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19496         unsigned char header_arr[80];
19497         CHECK(*((uint32_t*)header) == 80);
19498         memcpy(header_arr, (uint8_t*)(header + 4), 80);
19499         unsigned char (*header_ref)[80] = &header_arr;
19500         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19501         txdata_constr.datalen = *((uint32_t*)txdata);
19502         if (txdata_constr.datalen > 0)
19503                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19504         else
19505                 txdata_constr.data = NULL;
19506         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
19507         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19508                 uint32_t txdata_conv_28 = txdata_vals[c];
19509                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
19510                 CHECK_ACCESS(txdata_conv_28_ptr);
19511                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19512                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
19513                 txdata_constr.data[c] = txdata_conv_28_conv;
19514         }
19515         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19516         CHECK_ACCESS(broadcaster_ptr);
19517         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19518         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19519         CHECK_ACCESS(fee_estimator_ptr);
19520         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19521         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19522         CHECK_ACCESS(logger_ptr);
19523         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19524         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_transactions_confirmed(&this_arg_conv, header_ref, txdata_constr, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19525         uint32_tArray ret_arr = NULL;
19526         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19527         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19528         for (size_t n = 0; n < ret_var.datalen; n++) {
19529                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19530                 *ret_conv_39_conv = ret_var.data[n];
19531                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19532         }
19533         
19534         FREE(ret_var.data);
19535         return ret_arr;
19536 }
19537
19538 void  __attribute__((visibility("default"))) TS_ChannelMonitor_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19539         LDKChannelMonitor this_arg_conv;
19540         this_arg_conv.inner = (void*)(this_arg & (~1));
19541         this_arg_conv.is_owned = false;
19542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19543         unsigned char txid_arr[32];
19544         CHECK(*((uint32_t*)txid) == 32);
19545         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
19546         unsigned char (*txid_ref)[32] = &txid_arr;
19547         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19548         CHECK_ACCESS(broadcaster_ptr);
19549         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19550         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19551         CHECK_ACCESS(fee_estimator_ptr);
19552         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19553         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19554         CHECK_ACCESS(logger_ptr);
19555         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19556         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
19557 }
19558
19559 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
19560         LDKChannelMonitor this_arg_conv;
19561         this_arg_conv.inner = (void*)(this_arg & (~1));
19562         this_arg_conv.is_owned = false;
19563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19564         unsigned char header_arr[80];
19565         CHECK(*((uint32_t*)header) == 80);
19566         memcpy(header_arr, (uint8_t*)(header + 4), 80);
19567         unsigned char (*header_ref)[80] = &header_arr;
19568         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
19569         CHECK_ACCESS(broadcaster_ptr);
19570         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19571         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
19572         CHECK_ACCESS(fee_estimator_ptr);
19573         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19574         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
19575         CHECK_ACCESS(logger_ptr);
19576         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19577         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19578         uint32_tArray ret_arr = NULL;
19579         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19580         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19581         for (size_t n = 0; n < ret_var.datalen; n++) {
19582                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19583                 *ret_conv_39_conv = ret_var.data[n];
19584                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
19585         }
19586         
19587         FREE(ret_var.data);
19588         return ret_arr;
19589 }
19590
19591 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
19592         LDKChannelMonitor this_arg_conv;
19593         this_arg_conv.inner = (void*)(this_arg & (~1));
19594         this_arg_conv.is_owned = false;
19595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19596         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
19597         ptrArray ret_arr = NULL;
19598         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
19599         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
19600         for (size_t m = 0; m < ret_var.datalen; m++) {
19601                 int8_tArray ret_conv_12_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19602                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].data, 32);
19603                 ret_arr_ptr[m] = ret_conv_12_arr;
19604         }
19605         
19606         FREE(ret_var.data);
19607         return ret_arr;
19608 }
19609
19610 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
19611         LDKChannelMonitor this_arg_conv;
19612         this_arg_conv.inner = (void*)(this_arg & (~1));
19613         this_arg_conv.is_owned = false;
19614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19615         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
19616         uint64_t ret_ref = 0;
19617         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19618         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19620         ret_ref = (uint64_t)ret_var.inner;
19621         if (ret_var.is_owned) {
19622                 ret_ref |= 1;
19623         }
19624         return ret_ref;
19625 }
19626
19627 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
19628         LDKChannelMonitor this_arg_conv;
19629         this_arg_conv.inner = (void*)(this_arg & (~1));
19630         this_arg_conv.is_owned = false;
19631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19632         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
19633         uint32_tArray ret_arr = NULL;
19634         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
19635         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
19636         for (size_t j = 0; j < ret_var.datalen; j++) {
19637                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19638                 *ret_conv_9_copy = ret_var.data[j];
19639                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
19640                 ret_arr_ptr[j] = ret_conv_9_ref;
19641         }
19642         
19643         FREE(ret_var.data);
19644         return ret_arr;
19645 }
19646
19647 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
19648         LDKu8slice ser_ref;
19649         ser_ref.datalen = *((uint32_t*)ser);
19650         ser_ref.data = (int8_t*)(ser + 4);
19651         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
19652         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19653         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
19654         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19655         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
19656         return (uint64_t)ret_conv;
19657 }
19658
19659 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_obj) {
19660         LDKOutPoint this_obj_conv;
19661         this_obj_conv.inner = (void*)(this_obj & (~1));
19662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19664         OutPoint_free(this_obj_conv);
19665 }
19666
19667 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
19668         LDKOutPoint this_ptr_conv;
19669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19670         this_ptr_conv.is_owned = false;
19671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19672         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19673         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
19674         return ret_arr;
19675 }
19676
19677 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
19678         LDKOutPoint this_ptr_conv;
19679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19680         this_ptr_conv.is_owned = false;
19681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19682         LDKThirtyTwoBytes val_ref;
19683         CHECK(*((uint32_t*)val) == 32);
19684         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19685         OutPoint_set_txid(&this_ptr_conv, val_ref);
19686 }
19687
19688 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
19689         LDKOutPoint this_ptr_conv;
19690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19691         this_ptr_conv.is_owned = false;
19692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19693         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
19694         return ret_val;
19695 }
19696
19697 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
19698         LDKOutPoint this_ptr_conv;
19699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19700         this_ptr_conv.is_owned = false;
19701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19702         OutPoint_set_index(&this_ptr_conv, val);
19703 }
19704
19705 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
19706         LDKThirtyTwoBytes txid_arg_ref;
19707         CHECK(*((uint32_t*)txid_arg) == 32);
19708         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
19709         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
19710         uint64_t ret_ref = 0;
19711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19714         ret_ref = (uint64_t)ret_var.inner;
19715         if (ret_var.is_owned) {
19716                 ret_ref |= 1;
19717         }
19718         return ret_ref;
19719 }
19720
19721 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
19722         LDKOutPoint ret_var = OutPoint_clone(arg);
19723 uint64_t ret_ref = 0;
19724 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19725 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19726 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19727 ret_ref = (uint64_t)ret_var.inner;
19728 if (ret_var.is_owned) {
19729         ret_ref |= 1;
19730 }
19731         return ret_ref;
19732 }
19733 int64_t  __attribute__((visibility("default"))) TS_OutPoint_clone_ptr(uint32_t arg) {
19734         LDKOutPoint arg_conv;
19735         arg_conv.inner = (void*)(arg & (~1));
19736         arg_conv.is_owned = false;
19737         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19738         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
19739         return ret_val;
19740 }
19741
19742 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
19743         LDKOutPoint orig_conv;
19744         orig_conv.inner = (void*)(orig & (~1));
19745         orig_conv.is_owned = false;
19746         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19747         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
19748         uint64_t ret_ref = 0;
19749         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19750         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19752         ret_ref = (uint64_t)ret_var.inner;
19753         if (ret_var.is_owned) {
19754                 ret_ref |= 1;
19755         }
19756         return ret_ref;
19757 }
19758
19759 jboolean  __attribute__((visibility("default"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
19760         LDKOutPoint a_conv;
19761         a_conv.inner = (void*)(a & (~1));
19762         a_conv.is_owned = false;
19763         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19764         LDKOutPoint b_conv;
19765         b_conv.inner = (void*)(b & (~1));
19766         b_conv.is_owned = false;
19767         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19768         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
19769         return ret_val;
19770 }
19771
19772 int64_t  __attribute__((visibility("default"))) TS_OutPoint_hash(uint32_t o) {
19773         LDKOutPoint o_conv;
19774         o_conv.inner = (void*)(o & (~1));
19775         o_conv.is_owned = false;
19776         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19777         int64_t ret_val = OutPoint_hash(&o_conv);
19778         return ret_val;
19779 }
19780
19781 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
19782         LDKOutPoint this_arg_conv;
19783         this_arg_conv.inner = (void*)(this_arg & (~1));
19784         this_arg_conv.is_owned = false;
19785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19786         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19787         memcpy((uint8_t*)(ret_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
19788         return ret_arr;
19789 }
19790
19791 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
19792         LDKOutPoint obj_conv;
19793         obj_conv.inner = (void*)(obj & (~1));
19794         obj_conv.is_owned = false;
19795         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19796         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
19797         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
19798         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
19799         CVec_u8Z_free(ret_var);
19800         return ret_arr;
19801 }
19802
19803 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
19804         LDKu8slice ser_ref;
19805         ser_ref.datalen = *((uint32_t*)ser);
19806         ser_ref.data = (int8_t*)(ser + 4);
19807         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19808         *ret_conv = OutPoint_read(ser_ref);
19809         return (uint64_t)ret_conv;
19810 }
19811
19812 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
19813         LDKDelayedPaymentOutputDescriptor this_obj_conv;
19814         this_obj_conv.inner = (void*)(this_obj & (~1));
19815         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19817         DelayedPaymentOutputDescriptor_free(this_obj_conv);
19818 }
19819
19820 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19821         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19823         this_ptr_conv.is_owned = false;
19824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19825         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19826         uint64_t ret_ref = 0;
19827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19830         ret_ref = (uint64_t)ret_var.inner;
19831         if (ret_var.is_owned) {
19832                 ret_ref |= 1;
19833         }
19834         return ret_ref;
19835 }
19836
19837 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19838         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19840         this_ptr_conv.is_owned = false;
19841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19842         LDKOutPoint val_conv;
19843         val_conv.inner = (void*)(val & (~1));
19844         val_conv.is_owned = (val & 1) || (val == 0);
19845         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19846         val_conv = OutPoint_clone(&val_conv);
19847         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19848 }
19849
19850 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
19851         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19853         this_ptr_conv.is_owned = false;
19854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19855         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19856         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19857         return ret_arr;
19858 }
19859
19860 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19861         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19863         this_ptr_conv.is_owned = false;
19864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19865         LDKPublicKey val_ref;
19866         CHECK(*((uint32_t*)val) == 33);
19867         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19868         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
19869 }
19870
19871 int16_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
19872         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19874         this_ptr_conv.is_owned = false;
19875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19876         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
19877         return ret_val;
19878 }
19879
19880 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19881         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19883         this_ptr_conv.is_owned = false;
19884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19885         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
19886 }
19887
19888 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19889         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19891         this_ptr_conv.is_owned = false;
19892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19893         void* val_ptr = (void*)(((uint64_t)val) & ~1);
19894         CHECK_ACCESS(val_ptr);
19895         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19896         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
19897         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19898 }
19899
19900 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
19901         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19903         this_ptr_conv.is_owned = false;
19904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19905         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
19906         memcpy((uint8_t*)(ret_arr + 4), DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
19907         return ret_arr;
19908 }
19909
19910 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
19911         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19913         this_ptr_conv.is_owned = false;
19914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19915         LDKPublicKey val_ref;
19916         CHECK(*((uint32_t*)val) == 33);
19917         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
19918         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
19919 }
19920
19921 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19922         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19924         this_ptr_conv.is_owned = false;
19925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19926         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
19927         memcpy((uint8_t*)(ret_arr + 4), *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19928         return ret_arr;
19929 }
19930
19931 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19932         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19934         this_ptr_conv.is_owned = false;
19935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19936         LDKThirtyTwoBytes val_ref;
19937         CHECK(*((uint32_t*)val) == 32);
19938         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
19939         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19940 }
19941
19942 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19943         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19945         this_ptr_conv.is_owned = false;
19946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19947         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19948         return ret_val;
19949 }
19950
19951 void  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19952         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19954         this_ptr_conv.is_owned = false;
19955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19956         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19957 }
19958
19959 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_new(uint32_t outpoint_arg, int8_tArray per_commitment_point_arg, int16_t to_self_delay_arg, uint32_t output_arg, int8_tArray revocation_pubkey_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
19960         LDKOutPoint outpoint_arg_conv;
19961         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19962         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19963         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
19964         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19965         LDKPublicKey per_commitment_point_arg_ref;
19966         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
19967         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
19968         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
19969         CHECK_ACCESS(output_arg_ptr);
19970         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19971         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
19972         LDKPublicKey revocation_pubkey_arg_ref;
19973         CHECK(*((uint32_t*)revocation_pubkey_arg) == 33);
19974         memcpy(revocation_pubkey_arg_ref.compressed_form, (uint8_t*)(revocation_pubkey_arg + 4), 33);
19975         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19976         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
19977         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
19978         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_new(outpoint_arg_conv, per_commitment_point_arg_ref, to_self_delay_arg, output_arg_conv, revocation_pubkey_arg_ref, channel_keys_id_arg_ref, channel_value_satoshis_arg);
19979         uint64_t ret_ref = 0;
19980         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19981         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19983         ret_ref = (uint64_t)ret_var.inner;
19984         if (ret_var.is_owned) {
19985                 ret_ref |= 1;
19986         }
19987         return ret_ref;
19988 }
19989
19990 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
19991         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
19992 uint64_t ret_ref = 0;
19993 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19994 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19996 ret_ref = (uint64_t)ret_var.inner;
19997 if (ret_var.is_owned) {
19998         ret_ref |= 1;
19999 }
20000         return ret_ref;
20001 }
20002 int64_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
20003         LDKDelayedPaymentOutputDescriptor arg_conv;
20004         arg_conv.inner = (void*)(arg & (~1));
20005         arg_conv.is_owned = false;
20006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20007         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
20008         return ret_val;
20009 }
20010
20011 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
20012         LDKDelayedPaymentOutputDescriptor orig_conv;
20013         orig_conv.inner = (void*)(orig & (~1));
20014         orig_conv.is_owned = false;
20015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20016         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
20017         uint64_t ret_ref = 0;
20018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20021         ret_ref = (uint64_t)ret_var.inner;
20022         if (ret_var.is_owned) {
20023                 ret_ref |= 1;
20024         }
20025         return ret_ref;
20026 }
20027
20028 int8_tArray  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
20029         LDKDelayedPaymentOutputDescriptor obj_conv;
20030         obj_conv.inner = (void*)(obj & (~1));
20031         obj_conv.is_owned = false;
20032         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20033         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
20034         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20035         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20036         CVec_u8Z_free(ret_var);
20037         return ret_arr;
20038 }
20039
20040 uint32_t  __attribute__((visibility("default"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
20041         LDKu8slice ser_ref;
20042         ser_ref.datalen = *((uint32_t*)ser);
20043         ser_ref.data = (int8_t*)(ser + 4);
20044         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
20045         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
20046         return (uint64_t)ret_conv;
20047 }
20048
20049 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
20050         LDKStaticPaymentOutputDescriptor this_obj_conv;
20051         this_obj_conv.inner = (void*)(this_obj & (~1));
20052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20054         StaticPaymentOutputDescriptor_free(this_obj_conv);
20055 }
20056
20057 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
20058         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20060         this_ptr_conv.is_owned = false;
20061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20062         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
20063         uint64_t ret_ref = 0;
20064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20067         ret_ref = (uint64_t)ret_var.inner;
20068         if (ret_var.is_owned) {
20069                 ret_ref |= 1;
20070         }
20071         return ret_ref;
20072 }
20073
20074 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
20075         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20077         this_ptr_conv.is_owned = false;
20078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20079         LDKOutPoint val_conv;
20080         val_conv.inner = (void*)(val & (~1));
20081         val_conv.is_owned = (val & 1) || (val == 0);
20082         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20083         val_conv = OutPoint_clone(&val_conv);
20084         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
20085 }
20086
20087 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
20088         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20090         this_ptr_conv.is_owned = false;
20091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20092         void* val_ptr = (void*)(((uint64_t)val) & ~1);
20093         CHECK_ACCESS(val_ptr);
20094         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
20095         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
20096         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
20097 }
20098
20099 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
20100         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20102         this_ptr_conv.is_owned = false;
20103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20104         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20105         memcpy((uint8_t*)(ret_arr + 4), *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
20106         return ret_arr;
20107 }
20108
20109 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
20110         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20112         this_ptr_conv.is_owned = false;
20113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20114         LDKThirtyTwoBytes val_ref;
20115         CHECK(*((uint32_t*)val) == 32);
20116         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20117         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
20118 }
20119
20120 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
20121         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20123         this_ptr_conv.is_owned = false;
20124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20125         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
20126         return ret_val;
20127 }
20128
20129 void  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
20130         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20132         this_ptr_conv.is_owned = false;
20133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20134         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
20135 }
20136
20137 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_new(uint32_t outpoint_arg, uint32_t output_arg, int8_tArray channel_keys_id_arg, int64_t channel_value_satoshis_arg) {
20138         LDKOutPoint outpoint_arg_conv;
20139         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
20140         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
20141         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
20142         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
20143         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
20144         CHECK_ACCESS(output_arg_ptr);
20145         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
20146         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
20147         LDKThirtyTwoBytes channel_keys_id_arg_ref;
20148         CHECK(*((uint32_t*)channel_keys_id_arg) == 32);
20149         memcpy(channel_keys_id_arg_ref.data, (uint8_t*)(channel_keys_id_arg + 4), 32);
20150         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
20151         uint64_t ret_ref = 0;
20152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20155         ret_ref = (uint64_t)ret_var.inner;
20156         if (ret_var.is_owned) {
20157                 ret_ref |= 1;
20158         }
20159         return ret_ref;
20160 }
20161
20162 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
20163         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
20164 uint64_t ret_ref = 0;
20165 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20166 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20167 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20168 ret_ref = (uint64_t)ret_var.inner;
20169 if (ret_var.is_owned) {
20170         ret_ref |= 1;
20171 }
20172         return ret_ref;
20173 }
20174 int64_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
20175         LDKStaticPaymentOutputDescriptor arg_conv;
20176         arg_conv.inner = (void*)(arg & (~1));
20177         arg_conv.is_owned = false;
20178         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20179         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
20180         return ret_val;
20181 }
20182
20183 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
20184         LDKStaticPaymentOutputDescriptor orig_conv;
20185         orig_conv.inner = (void*)(orig & (~1));
20186         orig_conv.is_owned = false;
20187         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20188         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
20189         uint64_t ret_ref = 0;
20190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20193         ret_ref = (uint64_t)ret_var.inner;
20194         if (ret_var.is_owned) {
20195                 ret_ref |= 1;
20196         }
20197         return ret_ref;
20198 }
20199
20200 int8_tArray  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
20201         LDKStaticPaymentOutputDescriptor obj_conv;
20202         obj_conv.inner = (void*)(obj & (~1));
20203         obj_conv.is_owned = false;
20204         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20205         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
20206         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20207         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20208         CVec_u8Z_free(ret_var);
20209         return ret_arr;
20210 }
20211
20212 uint32_t  __attribute__((visibility("default"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
20213         LDKu8slice ser_ref;
20214         ser_ref.datalen = *((uint32_t*)ser);
20215         ser_ref.data = (int8_t*)(ser + 4);
20216         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20217         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
20218         return (uint64_t)ret_conv;
20219 }
20220
20221 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
20222         if ((this_ptr & 1) != 0) return;
20223         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20224         CHECK_ACCESS(this_ptr_ptr);
20225         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
20226         FREE((void*)this_ptr);
20227         SpendableOutputDescriptor_free(this_ptr_conv);
20228 }
20229
20230 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
20231         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20232         *ret_copy = SpendableOutputDescriptor_clone(arg);
20233 uint64_t ret_ref = (uint64_t)ret_copy;
20234         return ret_ref;
20235 }
20236 int64_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
20237         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
20238         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
20239         return ret_val;
20240 }
20241
20242 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
20243         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
20244         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20245         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
20246         uint64_t ret_ref = (uint64_t)ret_copy;
20247         return ret_ref;
20248 }
20249
20250 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
20251         LDKOutPoint outpoint_conv;
20252         outpoint_conv.inner = (void*)(outpoint & (~1));
20253         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
20254         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
20255         outpoint_conv = OutPoint_clone(&outpoint_conv);
20256         void* output_ptr = (void*)(((uint64_t)output) & ~1);
20257         CHECK_ACCESS(output_ptr);
20258         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
20259         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
20260         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20261         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
20262         uint64_t ret_ref = (uint64_t)ret_copy;
20263         return ret_ref;
20264 }
20265
20266 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
20267         LDKDelayedPaymentOutputDescriptor a_conv;
20268         a_conv.inner = (void*)(a & (~1));
20269         a_conv.is_owned = (a & 1) || (a == 0);
20270         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20271         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
20272         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20273         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
20274         uint64_t ret_ref = (uint64_t)ret_copy;
20275         return ret_ref;
20276 }
20277
20278 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
20279         LDKStaticPaymentOutputDescriptor a_conv;
20280         a_conv.inner = (void*)(a & (~1));
20281         a_conv.is_owned = (a & 1) || (a == 0);
20282         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20283         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
20284         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20285         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
20286         uint64_t ret_ref = (uint64_t)ret_copy;
20287         return ret_ref;
20288 }
20289
20290 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
20291         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
20292         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
20293         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20294         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20295         CVec_u8Z_free(ret_var);
20296         return ret_arr;
20297 }
20298
20299 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
20300         LDKu8slice ser_ref;
20301         ser_ref.datalen = *((uint32_t*)ser);
20302         ser_ref.data = (int8_t*)(ser + 4);
20303         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20304         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
20305         return (uint64_t)ret_conv;
20306 }
20307
20308 void  __attribute__((visibility("default"))) TS_BaseSign_free(uint32_t this_ptr) {
20309         if ((this_ptr & 1) != 0) return;
20310         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20311         CHECK_ACCESS(this_ptr_ptr);
20312         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
20313         FREE((void*)this_ptr);
20314         BaseSign_free(this_ptr_conv);
20315 }
20316
20317 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
20318         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20319         *ret_ret = Sign_clone(arg);
20320         return (uint64_t)ret_ret;
20321 }
20322 int64_t  __attribute__((visibility("default"))) TS_Sign_clone_ptr(uint32_t arg) {
20323         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
20324         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
20325         LDKSign* arg_conv = (LDKSign*)arg_ptr;
20326         int64_t ret_val = Sign_clone_ptr(arg_conv);
20327         return ret_val;
20328 }
20329
20330 uint32_t  __attribute__((visibility("default"))) TS_Sign_clone(uint32_t orig) {
20331         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
20332         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
20333         LDKSign* orig_conv = (LDKSign*)orig_ptr;
20334         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20335         *ret_ret = Sign_clone(orig_conv);
20336         return (uint64_t)ret_ret;
20337 }
20338
20339 void  __attribute__((visibility("default"))) TS_Sign_free(uint32_t this_ptr) {
20340         if ((this_ptr & 1) != 0) return;
20341         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20342         CHECK_ACCESS(this_ptr_ptr);
20343         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
20344         FREE((void*)this_ptr);
20345         Sign_free(this_ptr_conv);
20346 }
20347
20348 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
20349         if ((this_ptr & 1) != 0) return;
20350         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20351         CHECK_ACCESS(this_ptr_ptr);
20352         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
20353         FREE((void*)this_ptr);
20354         KeysInterface_free(this_ptr_conv);
20355 }
20356
20357 void  __attribute__((visibility("default"))) TS_InMemorySigner_free(uint32_t this_obj) {
20358         LDKInMemorySigner this_obj_conv;
20359         this_obj_conv.inner = (void*)(this_obj & (~1));
20360         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20362         InMemorySigner_free(this_obj_conv);
20363 }
20364
20365 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
20366         LDKInMemorySigner this_ptr_conv;
20367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20368         this_ptr_conv.is_owned = false;
20369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20370         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20371         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
20372         return ret_arr;
20373 }
20374
20375 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
20376         LDKInMemorySigner this_ptr_conv;
20377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20378         this_ptr_conv.is_owned = false;
20379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20380         LDKSecretKey val_ref;
20381         CHECK(*((uint32_t*)val) == 32);
20382         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
20383         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
20384 }
20385
20386 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
20387         LDKInMemorySigner this_ptr_conv;
20388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20389         this_ptr_conv.is_owned = false;
20390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20391         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20392         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
20393         return ret_arr;
20394 }
20395
20396 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
20397         LDKInMemorySigner this_ptr_conv;
20398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20399         this_ptr_conv.is_owned = false;
20400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20401         LDKSecretKey val_ref;
20402         CHECK(*((uint32_t*)val) == 32);
20403         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
20404         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
20405 }
20406
20407 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
20408         LDKInMemorySigner this_ptr_conv;
20409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20410         this_ptr_conv.is_owned = false;
20411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20412         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20413         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
20414         return ret_arr;
20415 }
20416
20417 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
20418         LDKInMemorySigner this_ptr_conv;
20419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20420         this_ptr_conv.is_owned = false;
20421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20422         LDKSecretKey val_ref;
20423         CHECK(*((uint32_t*)val) == 32);
20424         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
20425         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
20426 }
20427
20428 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
20429         LDKInMemorySigner this_ptr_conv;
20430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20431         this_ptr_conv.is_owned = false;
20432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20433         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20434         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
20435         return ret_arr;
20436 }
20437
20438 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
20439         LDKInMemorySigner this_ptr_conv;
20440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20441         this_ptr_conv.is_owned = false;
20442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20443         LDKSecretKey val_ref;
20444         CHECK(*((uint32_t*)val) == 32);
20445         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
20446         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
20447 }
20448
20449 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
20450         LDKInMemorySigner this_ptr_conv;
20451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20452         this_ptr_conv.is_owned = false;
20453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20454         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20455         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
20456         return ret_arr;
20457 }
20458
20459 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
20460         LDKInMemorySigner this_ptr_conv;
20461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20462         this_ptr_conv.is_owned = false;
20463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20464         LDKSecretKey val_ref;
20465         CHECK(*((uint32_t*)val) == 32);
20466         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
20467         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
20468 }
20469
20470 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
20471         LDKInMemorySigner this_ptr_conv;
20472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20473         this_ptr_conv.is_owned = false;
20474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20475         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
20476         memcpy((uint8_t*)(ret_arr + 4), *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
20477         return ret_arr;
20478 }
20479
20480 void  __attribute__((visibility("default"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
20481         LDKInMemorySigner this_ptr_conv;
20482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20483         this_ptr_conv.is_owned = false;
20484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20485         LDKThirtyTwoBytes val_ref;
20486         CHECK(*((uint32_t*)val) == 32);
20487         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
20488         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
20489 }
20490
20491 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
20492         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
20493 uint64_t ret_ref = 0;
20494 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20495 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20496 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20497 ret_ref = (uint64_t)ret_var.inner;
20498 if (ret_var.is_owned) {
20499         ret_ref |= 1;
20500 }
20501         return ret_ref;
20502 }
20503 int64_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
20504         LDKInMemorySigner arg_conv;
20505         arg_conv.inner = (void*)(arg & (~1));
20506         arg_conv.is_owned = false;
20507         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20508         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
20509         return ret_val;
20510 }
20511
20512 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_clone(uint32_t orig) {
20513         LDKInMemorySigner orig_conv;
20514         orig_conv.inner = (void*)(orig & (~1));
20515         orig_conv.is_owned = false;
20516         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20517         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
20518         uint64_t ret_ref = 0;
20519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20522         ret_ref = (uint64_t)ret_var.inner;
20523         if (ret_var.is_owned) {
20524                 ret_ref |= 1;
20525         }
20526         return ret_ref;
20527 }
20528
20529 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_new(int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
20530         LDKSecretKey funding_key_ref;
20531         CHECK(*((uint32_t*)funding_key) == 32);
20532         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
20533         LDKSecretKey revocation_base_key_ref;
20534         CHECK(*((uint32_t*)revocation_base_key) == 32);
20535         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
20536         LDKSecretKey payment_key_ref;
20537         CHECK(*((uint32_t*)payment_key) == 32);
20538         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
20539         LDKSecretKey delayed_payment_base_key_ref;
20540         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
20541         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
20542         LDKSecretKey htlc_base_key_ref;
20543         CHECK(*((uint32_t*)htlc_base_key) == 32);
20544         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
20545         LDKThirtyTwoBytes commitment_seed_ref;
20546         CHECK(*((uint32_t*)commitment_seed) == 32);
20547         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
20548         LDKThirtyTwoBytes channel_keys_id_ref;
20549         CHECK(*((uint32_t*)channel_keys_id) == 32);
20550         memcpy(channel_keys_id_ref.data, (uint8_t*)(channel_keys_id + 4), 32);
20551         LDKInMemorySigner ret_var = InMemorySigner_new(funding_key_ref, revocation_base_key_ref, payment_key_ref, delayed_payment_base_key_ref, htlc_base_key_ref, commitment_seed_ref, channel_value_satoshis, channel_keys_id_ref);
20552         uint64_t ret_ref = 0;
20553         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20554         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20556         ret_ref = (uint64_t)ret_var.inner;
20557         if (ret_var.is_owned) {
20558                 ret_ref |= 1;
20559         }
20560         return ret_ref;
20561 }
20562
20563 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
20564         LDKInMemorySigner this_arg_conv;
20565         this_arg_conv.inner = (void*)(this_arg & (~1));
20566         this_arg_conv.is_owned = false;
20567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20568         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
20569         uint64_t ret_ref = 0;
20570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20573         ret_ref = (uint64_t)ret_var.inner;
20574         if (ret_var.is_owned) {
20575                 ret_ref |= 1;
20576         }
20577         return ret_ref;
20578 }
20579
20580 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
20581         LDKInMemorySigner this_arg_conv;
20582         this_arg_conv.inner = (void*)(this_arg & (~1));
20583         this_arg_conv.is_owned = false;
20584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20585         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
20586         return ret_val;
20587 }
20588
20589 int16_t  __attribute__((visibility("default"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
20590         LDKInMemorySigner this_arg_conv;
20591         this_arg_conv.inner = (void*)(this_arg & (~1));
20592         this_arg_conv.is_owned = false;
20593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20594         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
20595         return ret_val;
20596 }
20597
20598 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
20599         LDKInMemorySigner this_arg_conv;
20600         this_arg_conv.inner = (void*)(this_arg & (~1));
20601         this_arg_conv.is_owned = false;
20602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20603         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
20604         return ret_val;
20605 }
20606
20607 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
20608         LDKInMemorySigner this_arg_conv;
20609         this_arg_conv.inner = (void*)(this_arg & (~1));
20610         this_arg_conv.is_owned = false;
20611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20612         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
20613         uint64_t ret_ref = 0;
20614         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20615         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20617         ret_ref = (uint64_t)ret_var.inner;
20618         if (ret_var.is_owned) {
20619                 ret_ref |= 1;
20620         }
20621         return ret_ref;
20622 }
20623
20624 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
20625         LDKInMemorySigner this_arg_conv;
20626         this_arg_conv.inner = (void*)(this_arg & (~1));
20627         this_arg_conv.is_owned = false;
20628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20629         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
20630         uint64_t ret_ref = 0;
20631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20634         ret_ref = (uint64_t)ret_var.inner;
20635         if (ret_var.is_owned) {
20636                 ret_ref |= 1;
20637         }
20638         return ret_ref;
20639 }
20640
20641 jboolean  __attribute__((visibility("default"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
20642         LDKInMemorySigner this_arg_conv;
20643         this_arg_conv.inner = (void*)(this_arg & (~1));
20644         this_arg_conv.is_owned = false;
20645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20646         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
20647         return ret_val;
20648 }
20649
20650 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_sign_counterparty_payment_input(uint32_t this_arg, int8_tArray spend_tx, int64_t input_idx, uint32_t descriptor) {
20651         LDKInMemorySigner this_arg_conv;
20652         this_arg_conv.inner = (void*)(this_arg & (~1));
20653         this_arg_conv.is_owned = false;
20654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20655         LDKTransaction spend_tx_ref;
20656         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
20657         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20658         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
20659         spend_tx_ref.data_is_owned = true;
20660         LDKStaticPaymentOutputDescriptor descriptor_conv;
20661         descriptor_conv.inner = (void*)(descriptor & (~1));
20662         descriptor_conv.is_owned = false;
20663         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20664         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20665         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20666         return (uint64_t)ret_conv;
20667 }
20668
20669 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_sign_dynamic_p2wsh_input(uint32_t this_arg, int8_tArray spend_tx, int64_t input_idx, uint32_t descriptor) {
20670         LDKInMemorySigner this_arg_conv;
20671         this_arg_conv.inner = (void*)(this_arg & (~1));
20672         this_arg_conv.is_owned = false;
20673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20674         LDKTransaction spend_tx_ref;
20675         spend_tx_ref.datalen = *((uint32_t*)spend_tx);
20676         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20677         memcpy(spend_tx_ref.data, (uint8_t*)(spend_tx + 4), spend_tx_ref.datalen);
20678         spend_tx_ref.data_is_owned = true;
20679         LDKDelayedPaymentOutputDescriptor descriptor_conv;
20680         descriptor_conv.inner = (void*)(descriptor & (~1));
20681         descriptor_conv.is_owned = false;
20682         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20683         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20684         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20685         return (uint64_t)ret_conv;
20686 }
20687
20688 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
20689         LDKInMemorySigner this_arg_conv;
20690         this_arg_conv.inner = (void*)(this_arg & (~1));
20691         this_arg_conv.is_owned = false;
20692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20693         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
20694         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
20695         return (uint64_t)ret_ret;
20696 }
20697
20698 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
20699         LDKInMemorySigner this_arg_conv;
20700         this_arg_conv.inner = (void*)(this_arg & (~1));
20701         this_arg_conv.is_owned = false;
20702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20703         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20704         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
20705         return (uint64_t)ret_ret;
20706 }
20707
20708 int8_tArray  __attribute__((visibility("default"))) TS_InMemorySigner_write(uint32_t obj) {
20709         LDKInMemorySigner obj_conv;
20710         obj_conv.inner = (void*)(obj & (~1));
20711         obj_conv.is_owned = false;
20712         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20713         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
20714         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
20715         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
20716         CVec_u8Z_free(ret_var);
20717         return ret_arr;
20718 }
20719
20720 uint32_t  __attribute__((visibility("default"))) TS_InMemorySigner_read(int8_tArray ser) {
20721         LDKu8slice ser_ref;
20722         ser_ref.datalen = *((uint32_t*)ser);
20723         ser_ref.data = (int8_t*)(ser + 4);
20724         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20725         *ret_conv = InMemorySigner_read(ser_ref);
20726         return (uint64_t)ret_conv;
20727 }
20728
20729 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_obj) {
20730         LDKKeysManager this_obj_conv;
20731         this_obj_conv.inner = (void*)(this_obj & (~1));
20732         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20734         KeysManager_free(this_obj_conv);
20735 }
20736
20737 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
20738         unsigned char seed_arr[32];
20739         CHECK(*((uint32_t*)seed) == 32);
20740         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
20741         unsigned char (*seed_ref)[32] = &seed_arr;
20742         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
20743         uint64_t ret_ref = 0;
20744         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20745         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20747         ret_ref = (uint64_t)ret_var.inner;
20748         if (ret_var.is_owned) {
20749                 ret_ref |= 1;
20750         }
20751         return ret_ref;
20752 }
20753
20754 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int8_tArray params) {
20755         LDKKeysManager this_arg_conv;
20756         this_arg_conv.inner = (void*)(this_arg & (~1));
20757         this_arg_conv.is_owned = false;
20758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20759         unsigned char params_arr[32];
20760         CHECK(*((uint32_t*)params) == 32);
20761         memcpy(params_arr, (uint8_t*)(params + 4), 32);
20762         unsigned char (*params_ref)[32] = &params_arr;
20763         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
20764         uint64_t ret_ref = 0;
20765         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20766         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20768         ret_ref = (uint64_t)ret_var.inner;
20769         if (ret_var.is_owned) {
20770                 ret_ref |= 1;
20771         }
20772         return ret_ref;
20773 }
20774
20775 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_spend_spendable_outputs(uint32_t this_arg, uint32_tArray descriptors, uint32_tArray outputs, int8_tArray change_destination_script, int32_t feerate_sat_per_1000_weight) {
20776         LDKKeysManager this_arg_conv;
20777         this_arg_conv.inner = (void*)(this_arg & (~1));
20778         this_arg_conv.is_owned = false;
20779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20780         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
20781         descriptors_constr.datalen = *((uint32_t*)descriptors);
20782         if (descriptors_constr.datalen > 0)
20783                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20784         else
20785                 descriptors_constr.data = NULL;
20786         uint32_t* descriptors_vals = (uint32_t*)(descriptors + 4);
20787         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
20788                 uint32_t descriptors_conv_27 = descriptors_vals[b];
20789                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
20790                 CHECK_ACCESS(descriptors_conv_27_ptr);
20791                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
20792                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
20793                 descriptors_constr.data[b] = descriptors_conv_27_conv;
20794         }
20795         LDKCVec_TxOutZ outputs_constr;
20796         outputs_constr.datalen = *((uint32_t*)outputs);
20797         if (outputs_constr.datalen > 0)
20798                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20799         else
20800                 outputs_constr.data = NULL;
20801         uint32_t* outputs_vals = (uint32_t*)(outputs + 4);
20802         for (size_t h = 0; h < outputs_constr.datalen; h++) {
20803                 uint32_t outputs_conv_7 = outputs_vals[h];
20804                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
20805                 CHECK_ACCESS(outputs_conv_7_ptr);
20806                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
20807                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
20808                 outputs_constr.data[h] = outputs_conv_7_conv;
20809         }
20810         LDKCVec_u8Z change_destination_script_ref;
20811         change_destination_script_ref.datalen = *((uint32_t*)change_destination_script);
20812         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
20813         memcpy(change_destination_script_ref.data, (uint8_t*)(change_destination_script + 4), change_destination_script_ref.datalen);
20814         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20815         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
20816         return (uint64_t)ret_conv;
20817 }
20818
20819 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
20820         LDKKeysManager this_arg_conv;
20821         this_arg_conv.inner = (void*)(this_arg & (~1));
20822         this_arg_conv.is_owned = false;
20823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20824         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
20825         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
20826         return (uint64_t)ret_ret;
20827 }
20828
20829 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_obj) {
20830         LDKChannelManager this_obj_conv;
20831         this_obj_conv.inner = (void*)(this_obj & (~1));
20832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20834         ChannelManager_free(this_obj_conv);
20835 }
20836
20837 void  __attribute__((visibility("default"))) TS_ChainParameters_free(uint32_t this_obj) {
20838         LDKChainParameters this_obj_conv;
20839         this_obj_conv.inner = (void*)(this_obj & (~1));
20840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20842         ChainParameters_free(this_obj_conv);
20843 }
20844
20845 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
20846         LDKChainParameters this_ptr_conv;
20847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20848         this_ptr_conv.is_owned = false;
20849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20850         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
20851         return ret_conv;
20852 }
20853
20854 void  __attribute__((visibility("default"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
20855         LDKChainParameters this_ptr_conv;
20856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20857         this_ptr_conv.is_owned = false;
20858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20859         LDKNetwork val_conv = LDKNetwork_from_js(val);
20860         ChainParameters_set_network(&this_ptr_conv, val_conv);
20861 }
20862
20863 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
20864         LDKChainParameters this_ptr_conv;
20865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20866         this_ptr_conv.is_owned = false;
20867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20868         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
20869         uint64_t ret_ref = 0;
20870         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20871         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20873         ret_ref = (uint64_t)ret_var.inner;
20874         if (ret_var.is_owned) {
20875                 ret_ref |= 1;
20876         }
20877         return ret_ref;
20878 }
20879
20880 void  __attribute__((visibility("default"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
20881         LDKChainParameters this_ptr_conv;
20882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20883         this_ptr_conv.is_owned = false;
20884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20885         LDKBestBlock val_conv;
20886         val_conv.inner = (void*)(val & (~1));
20887         val_conv.is_owned = (val & 1) || (val == 0);
20888         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20889         val_conv = BestBlock_clone(&val_conv);
20890         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
20891 }
20892
20893 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
20894         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
20895         LDKBestBlock best_block_arg_conv;
20896         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
20897         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
20898         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
20899         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
20900         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
20901         uint64_t ret_ref = 0;
20902         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20903         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20905         ret_ref = (uint64_t)ret_var.inner;
20906         if (ret_var.is_owned) {
20907                 ret_ref |= 1;
20908         }
20909         return ret_ref;
20910 }
20911
20912 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
20913         LDKChainParameters ret_var = ChainParameters_clone(arg);
20914 uint64_t ret_ref = 0;
20915 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20916 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20917 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20918 ret_ref = (uint64_t)ret_var.inner;
20919 if (ret_var.is_owned) {
20920         ret_ref |= 1;
20921 }
20922         return ret_ref;
20923 }
20924 int64_t  __attribute__((visibility("default"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
20925         LDKChainParameters arg_conv;
20926         arg_conv.inner = (void*)(arg & (~1));
20927         arg_conv.is_owned = false;
20928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20929         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
20930         return ret_val;
20931 }
20932
20933 uint32_t  __attribute__((visibility("default"))) TS_ChainParameters_clone(uint32_t orig) {
20934         LDKChainParameters orig_conv;
20935         orig_conv.inner = (void*)(orig & (~1));
20936         orig_conv.is_owned = false;
20937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20938         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
20939         uint64_t ret_ref = 0;
20940         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20941         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20943         ret_ref = (uint64_t)ret_var.inner;
20944         if (ret_var.is_owned) {
20945                 ret_ref |= 1;
20946         }
20947         return ret_ref;
20948 }
20949
20950 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
20951         LDKCounterpartyForwardingInfo this_obj_conv;
20952         this_obj_conv.inner = (void*)(this_obj & (~1));
20953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20955         CounterpartyForwardingInfo_free(this_obj_conv);
20956 }
20957
20958 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
20959         LDKCounterpartyForwardingInfo this_ptr_conv;
20960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20961         this_ptr_conv.is_owned = false;
20962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20963         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
20964         return ret_val;
20965 }
20966
20967 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
20968         LDKCounterpartyForwardingInfo this_ptr_conv;
20969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20970         this_ptr_conv.is_owned = false;
20971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20972         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
20973 }
20974
20975 int32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
20976         LDKCounterpartyForwardingInfo this_ptr_conv;
20977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20978         this_ptr_conv.is_owned = false;
20979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20980         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
20981         return ret_val;
20982 }
20983
20984 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
20985         LDKCounterpartyForwardingInfo this_ptr_conv;
20986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20987         this_ptr_conv.is_owned = false;
20988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20989         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
20990 }
20991
20992 int16_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20993         LDKCounterpartyForwardingInfo this_ptr_conv;
20994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20995         this_ptr_conv.is_owned = false;
20996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20997         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
20998         return ret_val;
20999 }
21000
21001 void  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21002         LDKCounterpartyForwardingInfo this_ptr_conv;
21003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21004         this_ptr_conv.is_owned = false;
21005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21006         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
21007 }
21008
21009 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_new(int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int16_t cltv_expiry_delta_arg) {
21010         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
21011         uint64_t ret_ref = 0;
21012         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21013         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21015         ret_ref = (uint64_t)ret_var.inner;
21016         if (ret_var.is_owned) {
21017                 ret_ref |= 1;
21018         }
21019         return ret_ref;
21020 }
21021
21022 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
21023         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
21024 uint64_t ret_ref = 0;
21025 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21026 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21027 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21028 ret_ref = (uint64_t)ret_var.inner;
21029 if (ret_var.is_owned) {
21030         ret_ref |= 1;
21031 }
21032         return ret_ref;
21033 }
21034 int64_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
21035         LDKCounterpartyForwardingInfo arg_conv;
21036         arg_conv.inner = (void*)(arg & (~1));
21037         arg_conv.is_owned = false;
21038         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21039         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
21040         return ret_val;
21041 }
21042
21043 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
21044         LDKCounterpartyForwardingInfo orig_conv;
21045         orig_conv.inner = (void*)(orig & (~1));
21046         orig_conv.is_owned = false;
21047         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21048         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
21049         uint64_t ret_ref = 0;
21050         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21051         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21053         ret_ref = (uint64_t)ret_var.inner;
21054         if (ret_var.is_owned) {
21055                 ret_ref |= 1;
21056         }
21057         return ret_ref;
21058 }
21059
21060 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
21061         LDKChannelCounterparty this_obj_conv;
21062         this_obj_conv.inner = (void*)(this_obj & (~1));
21063         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21065         ChannelCounterparty_free(this_obj_conv);
21066 }
21067
21068 int8_tArray  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
21069         LDKChannelCounterparty this_ptr_conv;
21070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21071         this_ptr_conv.is_owned = false;
21072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21073         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
21074         memcpy((uint8_t*)(ret_arr + 4), ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
21075         return ret_arr;
21076 }
21077
21078 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
21079         LDKChannelCounterparty this_ptr_conv;
21080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21081         this_ptr_conv.is_owned = false;
21082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21083         LDKPublicKey val_ref;
21084         CHECK(*((uint32_t*)val) == 33);
21085         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
21086         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
21087 }
21088
21089 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
21090         LDKChannelCounterparty this_ptr_conv;
21091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21092         this_ptr_conv.is_owned = false;
21093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21094         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
21095         uint64_t ret_ref = 0;
21096         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21097         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21099         ret_ref = (uint64_t)ret_var.inner;
21100         if (ret_var.is_owned) {
21101                 ret_ref |= 1;
21102         }
21103         return ret_ref;
21104 }
21105
21106 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
21107         LDKChannelCounterparty this_ptr_conv;
21108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21109         this_ptr_conv.is_owned = false;
21110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21111         LDKInitFeatures val_conv;
21112         val_conv.inner = (void*)(val & (~1));
21113         val_conv.is_owned = (val & 1) || (val == 0);
21114         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21115         val_conv = InitFeatures_clone(&val_conv);
21116         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
21117 }
21118
21119 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
21120         LDKChannelCounterparty this_ptr_conv;
21121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21122         this_ptr_conv.is_owned = false;
21123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21124         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
21125         return ret_val;
21126 }
21127
21128 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
21129         LDKChannelCounterparty this_ptr_conv;
21130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21131         this_ptr_conv.is_owned = false;
21132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21133         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
21134 }
21135
21136 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
21137         LDKChannelCounterparty this_ptr_conv;
21138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21139         this_ptr_conv.is_owned = false;
21140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21141         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
21142         uint64_t ret_ref = 0;
21143         if ((uint64_t)ret_var.inner > 4096) {
21144                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21145                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21147                 ret_ref = (uint64_t)ret_var.inner;
21148                 if (ret_var.is_owned) {
21149                         ret_ref |= 1;
21150                 }
21151         }
21152         return ret_ref;
21153 }
21154
21155 void  __attribute__((visibility("default"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
21156         LDKChannelCounterparty this_ptr_conv;
21157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21158         this_ptr_conv.is_owned = false;
21159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21160         LDKCounterpartyForwardingInfo val_conv;
21161         val_conv.inner = (void*)(val & (~1));
21162         val_conv.is_owned = (val & 1) || (val == 0);
21163         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21164         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
21165         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
21166 }
21167
21168 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_new(int8_tArray node_id_arg, uint32_t features_arg, int64_t unspendable_punishment_reserve_arg, uint32_t forwarding_info_arg) {
21169         LDKPublicKey node_id_arg_ref;
21170         CHECK(*((uint32_t*)node_id_arg) == 33);
21171         memcpy(node_id_arg_ref.compressed_form, (uint8_t*)(node_id_arg + 4), 33);
21172         LDKInitFeatures features_arg_conv;
21173         features_arg_conv.inner = (void*)(features_arg & (~1));
21174         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21175         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
21176         features_arg_conv = InitFeatures_clone(&features_arg_conv);
21177         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
21178         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
21179         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
21180         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
21181         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
21182         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
21183         uint64_t ret_ref = 0;
21184         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21185         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21187         ret_ref = (uint64_t)ret_var.inner;
21188         if (ret_var.is_owned) {
21189                 ret_ref |= 1;
21190         }
21191         return ret_ref;
21192 }
21193
21194 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
21195         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
21196 uint64_t ret_ref = 0;
21197 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21198 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21199 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21200 ret_ref = (uint64_t)ret_var.inner;
21201 if (ret_var.is_owned) {
21202         ret_ref |= 1;
21203 }
21204         return ret_ref;
21205 }
21206 int64_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
21207         LDKChannelCounterparty arg_conv;
21208         arg_conv.inner = (void*)(arg & (~1));
21209         arg_conv.is_owned = false;
21210         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21211         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
21212         return ret_val;
21213 }
21214
21215 uint32_t  __attribute__((visibility("default"))) TS_ChannelCounterparty_clone(uint32_t orig) {
21216         LDKChannelCounterparty orig_conv;
21217         orig_conv.inner = (void*)(orig & (~1));
21218         orig_conv.is_owned = false;
21219         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21220         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
21221         uint64_t ret_ref = 0;
21222         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21223         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21225         ret_ref = (uint64_t)ret_var.inner;
21226         if (ret_var.is_owned) {
21227                 ret_ref |= 1;
21228         }
21229         return ret_ref;
21230 }
21231
21232 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_obj) {
21233         LDKChannelDetails this_obj_conv;
21234         this_obj_conv.inner = (void*)(this_obj & (~1));
21235         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21237         ChannelDetails_free(this_obj_conv);
21238 }
21239
21240 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
21241         LDKChannelDetails this_ptr_conv;
21242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21243         this_ptr_conv.is_owned = false;
21244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21245         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
21246         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
21247         return ret_arr;
21248 }
21249
21250 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
21251         LDKChannelDetails this_ptr_conv;
21252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21253         this_ptr_conv.is_owned = false;
21254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21255         LDKThirtyTwoBytes val_ref;
21256         CHECK(*((uint32_t*)val) == 32);
21257         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
21258         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
21259 }
21260
21261 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
21262         LDKChannelDetails this_ptr_conv;
21263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21264         this_ptr_conv.is_owned = false;
21265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21266         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
21267         uint64_t ret_ref = 0;
21268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21271         ret_ref = (uint64_t)ret_var.inner;
21272         if (ret_var.is_owned) {
21273                 ret_ref |= 1;
21274         }
21275         return ret_ref;
21276 }
21277
21278 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
21279         LDKChannelDetails this_ptr_conv;
21280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21281         this_ptr_conv.is_owned = false;
21282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21283         LDKChannelCounterparty val_conv;
21284         val_conv.inner = (void*)(val & (~1));
21285         val_conv.is_owned = (val & 1) || (val == 0);
21286         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21287         val_conv = ChannelCounterparty_clone(&val_conv);
21288         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
21289 }
21290
21291 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
21292         LDKChannelDetails this_ptr_conv;
21293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21294         this_ptr_conv.is_owned = false;
21295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21296         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
21297         uint64_t ret_ref = 0;
21298         if ((uint64_t)ret_var.inner > 4096) {
21299                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21300                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21302                 ret_ref = (uint64_t)ret_var.inner;
21303                 if (ret_var.is_owned) {
21304                         ret_ref |= 1;
21305                 }
21306         }
21307         return ret_ref;
21308 }
21309
21310 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
21311         LDKChannelDetails this_ptr_conv;
21312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21313         this_ptr_conv.is_owned = false;
21314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21315         LDKOutPoint val_conv;
21316         val_conv.inner = (void*)(val & (~1));
21317         val_conv.is_owned = (val & 1) || (val == 0);
21318         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21319         val_conv = OutPoint_clone(&val_conv);
21320         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
21321 }
21322
21323 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
21324         LDKChannelDetails this_ptr_conv;
21325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21326         this_ptr_conv.is_owned = false;
21327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21328         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21329         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
21330         uint64_t ret_ref = (uint64_t)ret_copy;
21331         return ret_ref;
21332 }
21333
21334 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
21335         LDKChannelDetails this_ptr_conv;
21336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21337         this_ptr_conv.is_owned = false;
21338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21339         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21340         CHECK_ACCESS(val_ptr);
21341         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21342         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
21343         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
21344 }
21345
21346 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
21347         LDKChannelDetails this_ptr_conv;
21348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21349         this_ptr_conv.is_owned = false;
21350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21351         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
21352         return ret_val;
21353 }
21354
21355 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
21356         LDKChannelDetails this_ptr_conv;
21357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21358         this_ptr_conv.is_owned = false;
21359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21360         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
21361 }
21362
21363 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
21364         LDKChannelDetails this_ptr_conv;
21365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21366         this_ptr_conv.is_owned = false;
21367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21368         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21369         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
21370         uint64_t ret_ref = (uint64_t)ret_copy;
21371         return ret_ref;
21372 }
21373
21374 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
21375         LDKChannelDetails this_ptr_conv;
21376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21377         this_ptr_conv.is_owned = false;
21378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21379         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21380         CHECK_ACCESS(val_ptr);
21381         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21382         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
21383         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
21384 }
21385
21386 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
21387         LDKChannelDetails this_ptr_conv;
21388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21389         this_ptr_conv.is_owned = false;
21390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21391         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
21392         return ret_val;
21393 }
21394
21395 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
21396         LDKChannelDetails this_ptr_conv;
21397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21398         this_ptr_conv.is_owned = false;
21399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21400         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
21401 }
21402
21403 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
21404         LDKChannelDetails this_ptr_conv;
21405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21406         this_ptr_conv.is_owned = false;
21407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21408         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
21409         return ret_val;
21410 }
21411
21412 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
21413         LDKChannelDetails this_ptr_conv;
21414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21415         this_ptr_conv.is_owned = false;
21416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21417         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
21418 }
21419
21420 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
21421         LDKChannelDetails this_ptr_conv;
21422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21423         this_ptr_conv.is_owned = false;
21424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21425         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
21426         return ret_val;
21427 }
21428
21429 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21430         LDKChannelDetails this_ptr_conv;
21431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21432         this_ptr_conv.is_owned = false;
21433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21434         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
21435 }
21436
21437 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
21438         LDKChannelDetails this_ptr_conv;
21439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21440         this_ptr_conv.is_owned = false;
21441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21442         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
21443         return ret_val;
21444 }
21445
21446 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21447         LDKChannelDetails this_ptr_conv;
21448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21449         this_ptr_conv.is_owned = false;
21450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21451         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
21452 }
21453
21454 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
21455         LDKChannelDetails this_ptr_conv;
21456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21457         this_ptr_conv.is_owned = false;
21458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21459         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21460         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
21461         uint64_t ret_ref = (uint64_t)ret_copy;
21462         return ret_ref;
21463 }
21464
21465 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
21466         LDKChannelDetails this_ptr_conv;
21467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21468         this_ptr_conv.is_owned = false;
21469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21470         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21471         CHECK_ACCESS(val_ptr);
21472         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
21473         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
21474         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
21475 }
21476
21477 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
21478         LDKChannelDetails this_ptr_conv;
21479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21480         this_ptr_conv.is_owned = false;
21481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21482         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21483         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
21484         uint64_t ret_ref = (uint64_t)ret_copy;
21485         return ret_ref;
21486 }
21487
21488 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_force_close_spend_delay(uint32_t this_ptr, uint32_t val) {
21489         LDKChannelDetails this_ptr_conv;
21490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21491         this_ptr_conv.is_owned = false;
21492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21493         void* val_ptr = (void*)(((uint64_t)val) & ~1);
21494         CHECK_ACCESS(val_ptr);
21495         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
21496         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
21497         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
21498 }
21499
21500 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
21501         LDKChannelDetails this_ptr_conv;
21502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21503         this_ptr_conv.is_owned = false;
21504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21505         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
21506         return ret_val;
21507 }
21508
21509 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
21510         LDKChannelDetails this_ptr_conv;
21511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21512         this_ptr_conv.is_owned = false;
21513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21514         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
21515 }
21516
21517 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
21518         LDKChannelDetails this_ptr_conv;
21519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21520         this_ptr_conv.is_owned = false;
21521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21522         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
21523         return ret_val;
21524 }
21525
21526 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
21527         LDKChannelDetails this_ptr_conv;
21528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21529         this_ptr_conv.is_owned = false;
21530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21531         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
21532 }
21533
21534 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
21535         LDKChannelDetails this_ptr_conv;
21536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21537         this_ptr_conv.is_owned = false;
21538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21539         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
21540         return ret_val;
21541 }
21542
21543 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
21544         LDKChannelDetails this_ptr_conv;
21545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21546         this_ptr_conv.is_owned = false;
21547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21548         ChannelDetails_set_is_usable(&this_ptr_conv, val);
21549 }
21550
21551 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
21552         LDKChannelDetails this_ptr_conv;
21553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21554         this_ptr_conv.is_owned = false;
21555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21556         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
21557         return ret_val;
21558 }
21559
21560 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
21561         LDKChannelDetails this_ptr_conv;
21562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21563         this_ptr_conv.is_owned = false;
21564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21565         ChannelDetails_set_is_public(&this_ptr_conv, val);
21566 }
21567
21568 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_new(int8_tArray channel_id_arg, uint32_t counterparty_arg, uint32_t funding_txo_arg, uint32_t short_channel_id_arg, int64_t channel_value_satoshis_arg, uint32_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
21569         LDKThirtyTwoBytes channel_id_arg_ref;
21570         CHECK(*((uint32_t*)channel_id_arg) == 32);
21571         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
21572         LDKChannelCounterparty counterparty_arg_conv;
21573         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
21574         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
21575         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
21576         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
21577         LDKOutPoint funding_txo_arg_conv;
21578         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
21579         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
21580         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
21581         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
21582         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
21583         CHECK_ACCESS(short_channel_id_arg_ptr);
21584         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
21585         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
21586         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
21587         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
21588         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
21589         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
21590         CHECK_ACCESS(confirmations_required_arg_ptr);
21591         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
21592         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
21593         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
21594         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
21595         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
21596         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
21597         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
21598         uint64_t ret_ref = 0;
21599         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21600         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21602         ret_ref = (uint64_t)ret_var.inner;
21603         if (ret_var.is_owned) {
21604                 ret_ref |= 1;
21605         }
21606         return ret_ref;
21607 }
21608
21609 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
21610         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
21611 uint64_t ret_ref = 0;
21612 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21613 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21614 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21615 ret_ref = (uint64_t)ret_var.inner;
21616 if (ret_var.is_owned) {
21617         ret_ref |= 1;
21618 }
21619         return ret_ref;
21620 }
21621 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
21622         LDKChannelDetails arg_conv;
21623         arg_conv.inner = (void*)(arg & (~1));
21624         arg_conv.is_owned = false;
21625         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21626         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
21627         return ret_val;
21628 }
21629
21630 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
21631         LDKChannelDetails orig_conv;
21632         orig_conv.inner = (void*)(orig & (~1));
21633         orig_conv.is_owned = false;
21634         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21635         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
21636         uint64_t ret_ref = 0;
21637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21640         ret_ref = (uint64_t)ret_var.inner;
21641         if (ret_var.is_owned) {
21642                 ret_ref |= 1;
21643         }
21644         return ret_ref;
21645 }
21646
21647 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
21648         if ((this_ptr & 1) != 0) return;
21649         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21650         CHECK_ACCESS(this_ptr_ptr);
21651         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
21652         FREE((void*)this_ptr);
21653         PaymentSendFailure_free(this_ptr_conv);
21654 }
21655
21656 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
21657         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21658         *ret_copy = PaymentSendFailure_clone(arg);
21659 uint64_t ret_ref = (uint64_t)ret_copy;
21660         return ret_ref;
21661 }
21662 int64_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
21663         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
21664         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
21665         return ret_val;
21666 }
21667
21668 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
21669         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
21670         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21671         *ret_copy = PaymentSendFailure_clone(orig_conv);
21672         uint64_t ret_ref = (uint64_t)ret_copy;
21673         return ret_ref;
21674 }
21675
21676 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
21677         void* a_ptr = (void*)(((uint64_t)a) & ~1);
21678         CHECK_ACCESS(a_ptr);
21679         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
21680         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
21681         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21682         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
21683         uint64_t ret_ref = (uint64_t)ret_copy;
21684         return ret_ref;
21685 }
21686
21687 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
21688         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
21689         a_constr.datalen = *((uint32_t*)a);
21690         if (a_constr.datalen > 0)
21691                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21692         else
21693                 a_constr.data = NULL;
21694         uint32_t* a_vals = (uint32_t*)(a + 4);
21695         for (size_t w = 0; w < a_constr.datalen; w++) {
21696                 uint32_t a_conv_22 = a_vals[w];
21697                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
21698                 CHECK_ACCESS(a_conv_22_ptr);
21699                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
21700                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
21701                 a_constr.data[w] = a_conv_22_conv;
21702         }
21703         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21704         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
21705         uint64_t ret_ref = (uint64_t)ret_copy;
21706         return ret_ref;
21707 }
21708
21709 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
21710         LDKCVec_APIErrorZ a_constr;
21711         a_constr.datalen = *((uint32_t*)a);
21712         if (a_constr.datalen > 0)
21713                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
21714         else
21715                 a_constr.data = NULL;
21716         uint32_t* a_vals = (uint32_t*)(a + 4);
21717         for (size_t k = 0; k < a_constr.datalen; k++) {
21718                 uint32_t a_conv_10 = a_vals[k];
21719                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
21720                 CHECK_ACCESS(a_conv_10_ptr);
21721                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
21722                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
21723                 a_constr.data[k] = a_conv_10_conv;
21724         }
21725         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21726         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
21727         uint64_t ret_ref = (uint64_t)ret_copy;
21728         return ret_ref;
21729 }
21730
21731 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_partial_failure(uint32_tArray results, uint32_t failed_paths_retry, int8_tArray payment_id) {
21732         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
21733         results_constr.datalen = *((uint32_t*)results);
21734         if (results_constr.datalen > 0)
21735                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21736         else
21737                 results_constr.data = NULL;
21738         uint32_t* results_vals = (uint32_t*)(results + 4);
21739         for (size_t w = 0; w < results_constr.datalen; w++) {
21740                 uint32_t results_conv_22 = results_vals[w];
21741                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
21742                 CHECK_ACCESS(results_conv_22_ptr);
21743                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
21744                 results_constr.data[w] = results_conv_22_conv;
21745         }
21746         LDKRouteParameters failed_paths_retry_conv;
21747         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
21748         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
21749         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
21750         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
21751         LDKThirtyTwoBytes payment_id_ref;
21752         CHECK(*((uint32_t*)payment_id) == 32);
21753         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
21754         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21755         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
21756         uint64_t ret_ref = (uint64_t)ret_copy;
21757         return ret_ref;
21758 }
21759
21760 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, uint32_t params) {
21761         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
21762         CHECK_ACCESS(fee_est_ptr);
21763         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
21764         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
21765         CHECK_ACCESS(chain_monitor_ptr);
21766         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21767         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
21768         CHECK_ACCESS(tx_broadcaster_ptr);
21769         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21770         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21771         CHECK_ACCESS(logger_ptr);
21772         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21773         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
21774         CHECK_ACCESS(keys_manager_ptr);
21775         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21776         LDKUserConfig config_conv;
21777         config_conv.inner = (void*)(config & (~1));
21778         config_conv.is_owned = (config & 1) || (config == 0);
21779         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
21780         config_conv = UserConfig_clone(&config_conv);
21781         LDKChainParameters params_conv;
21782         params_conv.inner = (void*)(params & (~1));
21783         params_conv.is_owned = (params & 1) || (params == 0);
21784         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
21785         params_conv = ChainParameters_clone(&params_conv);
21786         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
21787         uint64_t ret_ref = 0;
21788         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21789         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21791         ret_ref = (uint64_t)ret_var.inner;
21792         if (ret_var.is_owned) {
21793                 ret_ref |= 1;
21794         }
21795         return ret_ref;
21796 }
21797
21798 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
21799         LDKChannelManager this_arg_conv;
21800         this_arg_conv.inner = (void*)(this_arg & (~1));
21801         this_arg_conv.is_owned = false;
21802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21803         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
21804         uint64_t ret_ref = 0;
21805         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21806         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21808         ret_ref = (uint64_t)ret_var.inner;
21809         if (ret_var.is_owned) {
21810                 ret_ref |= 1;
21811         }
21812         return ret_ref;
21813 }
21814
21815 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_channel_id, uint32_t override_config) {
21816         LDKChannelManager this_arg_conv;
21817         this_arg_conv.inner = (void*)(this_arg & (~1));
21818         this_arg_conv.is_owned = false;
21819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21820         LDKPublicKey their_network_key_ref;
21821         CHECK(*((uint32_t*)their_network_key) == 33);
21822         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
21823         LDKUserConfig override_config_conv;
21824         override_config_conv.inner = (void*)(override_config & (~1));
21825         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
21826         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
21827         override_config_conv = UserConfig_clone(&override_config_conv);
21828         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21829         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
21830         return (uint64_t)ret_conv;
21831 }
21832
21833 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
21834         LDKChannelManager this_arg_conv;
21835         this_arg_conv.inner = (void*)(this_arg & (~1));
21836         this_arg_conv.is_owned = false;
21837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21838         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
21839         uint32_tArray ret_arr = NULL;
21840         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
21841         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
21842         for (size_t q = 0; q < ret_var.datalen; q++) {
21843                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21844                 uint64_t ret_conv_16_ref = 0;
21845                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21846                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21847                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21848                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21849                 if (ret_conv_16_var.is_owned) {
21850                         ret_conv_16_ref |= 1;
21851                 }
21852                 ret_arr_ptr[q] = ret_conv_16_ref;
21853         }
21854         
21855         FREE(ret_var.data);
21856         return ret_arr;
21857 }
21858
21859 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
21860         LDKChannelManager this_arg_conv;
21861         this_arg_conv.inner = (void*)(this_arg & (~1));
21862         this_arg_conv.is_owned = false;
21863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21864         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
21865         uint32_tArray ret_arr = NULL;
21866         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
21867         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
21868         for (size_t q = 0; q < ret_var.datalen; q++) {
21869                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21870                 uint64_t ret_conv_16_ref = 0;
21871                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21872                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21873                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21874                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
21875                 if (ret_conv_16_var.is_owned) {
21876                         ret_conv_16_ref |= 1;
21877                 }
21878                 ret_arr_ptr[q] = ret_conv_16_ref;
21879         }
21880         
21881         FREE(ret_var.data);
21882         return ret_arr;
21883 }
21884
21885 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21886         LDKChannelManager this_arg_conv;
21887         this_arg_conv.inner = (void*)(this_arg & (~1));
21888         this_arg_conv.is_owned = false;
21889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21890         unsigned char channel_id_arr[32];
21891         CHECK(*((uint32_t*)channel_id) == 32);
21892         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
21893         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21894         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21895         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
21896         return (uint64_t)ret_conv;
21897 }
21898
21899 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel_with_target_feerate(uint32_t this_arg, int8_tArray channel_id, int32_t target_feerate_sats_per_1000_weight) {
21900         LDKChannelManager this_arg_conv;
21901         this_arg_conv.inner = (void*)(this_arg & (~1));
21902         this_arg_conv.is_owned = false;
21903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21904         unsigned char channel_id_arr[32];
21905         CHECK(*((uint32_t*)channel_id) == 32);
21906         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
21907         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21908         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21909         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
21910         return (uint64_t)ret_conv;
21911 }
21912
21913 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21914         LDKChannelManager this_arg_conv;
21915         this_arg_conv.inner = (void*)(this_arg & (~1));
21916         this_arg_conv.is_owned = false;
21917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21918         unsigned char channel_id_arr[32];
21919         CHECK(*((uint32_t*)channel_id) == 32);
21920         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
21921         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21922         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21923         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
21924         return (uint64_t)ret_conv;
21925 }
21926
21927 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
21928         LDKChannelManager this_arg_conv;
21929         this_arg_conv.inner = (void*)(this_arg & (~1));
21930         this_arg_conv.is_owned = false;
21931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21932         ChannelManager_force_close_all_channels(&this_arg_conv);
21933 }
21934
21935 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
21936         LDKChannelManager this_arg_conv;
21937         this_arg_conv.inner = (void*)(this_arg & (~1));
21938         this_arg_conv.is_owned = false;
21939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21940         LDKRoute route_conv;
21941         route_conv.inner = (void*)(route & (~1));
21942         route_conv.is_owned = false;
21943         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21944         LDKThirtyTwoBytes payment_hash_ref;
21945         CHECK(*((uint32_t*)payment_hash) == 32);
21946         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
21947         LDKThirtyTwoBytes payment_secret_ref;
21948         CHECK(*((uint32_t*)payment_secret) == 32);
21949         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
21950         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
21951         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
21952         return (uint64_t)ret_conv;
21953 }
21954
21955 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
21956         LDKChannelManager this_arg_conv;
21957         this_arg_conv.inner = (void*)(this_arg & (~1));
21958         this_arg_conv.is_owned = false;
21959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21960         LDKRoute route_conv;
21961         route_conv.inner = (void*)(route & (~1));
21962         route_conv.is_owned = false;
21963         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21964         LDKThirtyTwoBytes payment_id_ref;
21965         CHECK(*((uint32_t*)payment_id) == 32);
21966         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
21967         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21968         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
21969         return (uint64_t)ret_conv;
21970 }
21971
21972 void  __attribute__((visibility("default"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
21973         LDKChannelManager this_arg_conv;
21974         this_arg_conv.inner = (void*)(this_arg & (~1));
21975         this_arg_conv.is_owned = false;
21976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21977         LDKThirtyTwoBytes payment_id_ref;
21978         CHECK(*((uint32_t*)payment_id) == 32);
21979         memcpy(payment_id_ref.data, (uint8_t*)(payment_id + 4), 32);
21980         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
21981 }
21982
21983 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_spontaneous_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_preimage) {
21984         LDKChannelManager this_arg_conv;
21985         this_arg_conv.inner = (void*)(this_arg & (~1));
21986         this_arg_conv.is_owned = false;
21987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21988         LDKRoute route_conv;
21989         route_conv.inner = (void*)(route & (~1));
21990         route_conv.is_owned = false;
21991         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21992         LDKThirtyTwoBytes payment_preimage_ref;
21993         CHECK(*((uint32_t*)payment_preimage) == 32);
21994         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
21995         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21996         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
21997         return (uint64_t)ret_conv;
21998 }
21999
22000 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, int8_tArray funding_transaction) {
22001         LDKChannelManager this_arg_conv;
22002         this_arg_conv.inner = (void*)(this_arg & (~1));
22003         this_arg_conv.is_owned = false;
22004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22005         unsigned char temporary_channel_id_arr[32];
22006         CHECK(*((uint32_t*)temporary_channel_id) == 32);
22007         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
22008         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
22009         LDKTransaction funding_transaction_ref;
22010         funding_transaction_ref.datalen = *((uint32_t*)funding_transaction);
22011         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
22012         memcpy(funding_transaction_ref.data, (uint8_t*)(funding_transaction + 4), funding_transaction_ref.datalen);
22013         funding_transaction_ref.data_is_owned = true;
22014         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
22015         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
22016         return (uint64_t)ret_conv;
22017 }
22018
22019 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
22020         LDKChannelManager this_arg_conv;
22021         this_arg_conv.inner = (void*)(this_arg & (~1));
22022         this_arg_conv.is_owned = false;
22023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22024         LDKThreeBytes rgb_ref;
22025         CHECK(*((uint32_t*)rgb) == 3);
22026         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
22027         LDKThirtyTwoBytes alias_ref;
22028         CHECK(*((uint32_t*)alias) == 32);
22029         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
22030         LDKCVec_NetAddressZ addresses_constr;
22031         addresses_constr.datalen = *((uint32_t*)addresses);
22032         if (addresses_constr.datalen > 0)
22033                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
22034         else
22035                 addresses_constr.data = NULL;
22036         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
22037         for (size_t m = 0; m < addresses_constr.datalen; m++) {
22038                 uint32_t addresses_conv_12 = addresses_vals[m];
22039                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
22040                 CHECK_ACCESS(addresses_conv_12_ptr);
22041                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
22042                 addresses_constr.data[m] = addresses_conv_12_conv;
22043         }
22044         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
22045 }
22046
22047 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
22048         LDKChannelManager this_arg_conv;
22049         this_arg_conv.inner = (void*)(this_arg & (~1));
22050         this_arg_conv.is_owned = false;
22051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22052         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
22053 }
22054
22055 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
22056         LDKChannelManager this_arg_conv;
22057         this_arg_conv.inner = (void*)(this_arg & (~1));
22058         this_arg_conv.is_owned = false;
22059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22060         ChannelManager_timer_tick_occurred(&this_arg_conv);
22061 }
22062
22063 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
22064         LDKChannelManager this_arg_conv;
22065         this_arg_conv.inner = (void*)(this_arg & (~1));
22066         this_arg_conv.is_owned = false;
22067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22068         unsigned char payment_hash_arr[32];
22069         CHECK(*((uint32_t*)payment_hash) == 32);
22070         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
22071         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
22072         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
22073         return ret_val;
22074 }
22075
22076 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
22077         LDKChannelManager this_arg_conv;
22078         this_arg_conv.inner = (void*)(this_arg & (~1));
22079         this_arg_conv.is_owned = false;
22080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22081         LDKThirtyTwoBytes payment_preimage_ref;
22082         CHECK(*((uint32_t*)payment_preimage) == 32);
22083         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
22084         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
22085         return ret_val;
22086 }
22087
22088 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
22089         LDKChannelManager this_arg_conv;
22090         this_arg_conv.inner = (void*)(this_arg & (~1));
22091         this_arg_conv.is_owned = false;
22092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22093         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
22094         memcpy((uint8_t*)(ret_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
22095         return ret_arr;
22096 }
22097
22098 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
22099         LDKChannelManager this_arg_conv;
22100         this_arg_conv.inner = (void*)(this_arg & (~1));
22101         this_arg_conv.is_owned = false;
22102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22103         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
22104         CHECK_ACCESS(min_value_msat_ptr);
22105         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22106         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
22107         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
22108         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
22109         return (uint64_t)ret_conv;
22110 }
22111
22112 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment_legacy(uint32_t this_arg, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
22113         LDKChannelManager this_arg_conv;
22114         this_arg_conv.inner = (void*)(this_arg & (~1));
22115         this_arg_conv.is_owned = false;
22116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22117         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
22118         CHECK_ACCESS(min_value_msat_ptr);
22119         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22120         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
22121         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
22122         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
22123         return (uint64_t)ret_conv;
22124 }
22125
22126 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment_for_hash(uint32_t this_arg, int8_tArray payment_hash, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
22127         LDKChannelManager this_arg_conv;
22128         this_arg_conv.inner = (void*)(this_arg & (~1));
22129         this_arg_conv.is_owned = false;
22130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22131         LDKThirtyTwoBytes payment_hash_ref;
22132         CHECK(*((uint32_t*)payment_hash) == 32);
22133         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
22134         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
22135         CHECK_ACCESS(min_value_msat_ptr);
22136         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22137         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
22138         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22139         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22140         return (uint64_t)ret_conv;
22141 }
22142
22143 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_create_inbound_payment_for_hash_legacy(uint32_t this_arg, int8_tArray payment_hash, uint32_t min_value_msat, int32_t invoice_expiry_delta_secs) {
22144         LDKChannelManager this_arg_conv;
22145         this_arg_conv.inner = (void*)(this_arg & (~1));
22146         this_arg_conv.is_owned = false;
22147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22148         LDKThirtyTwoBytes payment_hash_ref;
22149         CHECK(*((uint32_t*)payment_hash) == 32);
22150         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
22151         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
22152         CHECK_ACCESS(min_value_msat_ptr);
22153         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22154         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
22155         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22156         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22157         return (uint64_t)ret_conv;
22158 }
22159
22160 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_get_payment_preimage(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
22161         LDKChannelManager this_arg_conv;
22162         this_arg_conv.inner = (void*)(this_arg & (~1));
22163         this_arg_conv.is_owned = false;
22164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22165         LDKThirtyTwoBytes payment_hash_ref;
22166         CHECK(*((uint32_t*)payment_hash) == 32);
22167         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
22168         LDKThirtyTwoBytes payment_secret_ref;
22169         CHECK(*((uint32_t*)payment_secret) == 32);
22170         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
22171         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22172         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
22173         return (uint64_t)ret_conv;
22174 }
22175
22176 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
22177         LDKChannelManager this_arg_conv;
22178         this_arg_conv.inner = (void*)(this_arg & (~1));
22179         this_arg_conv.is_owned = false;
22180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22181         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22182         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
22183         return (uint64_t)ret_ret;
22184 }
22185
22186 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
22187         LDKChannelManager this_arg_conv;
22188         this_arg_conv.inner = (void*)(this_arg & (~1));
22189         this_arg_conv.is_owned = false;
22190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22191         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22192         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
22193         return (uint64_t)ret_ret;
22194 }
22195
22196 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
22197         LDKChannelManager this_arg_conv;
22198         this_arg_conv.inner = (void*)(this_arg & (~1));
22199         this_arg_conv.is_owned = false;
22200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22201         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22202         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
22203         return (uint64_t)ret_ret;
22204 }
22205
22206 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
22207         LDKChannelManager this_arg_conv;
22208         this_arg_conv.inner = (void*)(this_arg & (~1));
22209         this_arg_conv.is_owned = false;
22210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22211         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22212         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
22213         return (uint64_t)ret_ret;
22214 }
22215
22216 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update_timeout(uint32_t this_arg, int64_t max_wait) {
22217         LDKChannelManager this_arg_conv;
22218         this_arg_conv.inner = (void*)(this_arg & (~1));
22219         this_arg_conv.is_owned = false;
22220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22221         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
22222         return ret_val;
22223 }
22224
22225 void  __attribute__((visibility("default"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
22226         LDKChannelManager this_arg_conv;
22227         this_arg_conv.inner = (void*)(this_arg & (~1));
22228         this_arg_conv.is_owned = false;
22229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22230         ChannelManager_await_persistable_update(&this_arg_conv);
22231 }
22232
22233 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
22234         LDKChannelManager this_arg_conv;
22235         this_arg_conv.inner = (void*)(this_arg & (~1));
22236         this_arg_conv.is_owned = false;
22237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22238         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
22239         uint64_t ret_ref = 0;
22240         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22241         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22243         ret_ref = (uint64_t)ret_var.inner;
22244         if (ret_var.is_owned) {
22245                 ret_ref |= 1;
22246         }
22247         return ret_ref;
22248 }
22249
22250 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
22251         LDKChannelManager this_arg_conv;
22252         this_arg_conv.inner = (void*)(this_arg & (~1));
22253         this_arg_conv.is_owned = false;
22254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22255         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
22256         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
22257         return (uint64_t)ret_ret;
22258 }
22259
22260 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
22261         LDKChannelManager obj_conv;
22262         obj_conv.inner = (void*)(obj & (~1));
22263         obj_conv.is_owned = false;
22264         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22265         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
22266         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
22267         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
22268         CVec_u8Z_free(ret_var);
22269         return ret_arr;
22270 }
22271
22272 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
22273         LDKChannelManagerReadArgs this_obj_conv;
22274         this_obj_conv.inner = (void*)(this_obj & (~1));
22275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22277         ChannelManagerReadArgs_free(this_obj_conv);
22278 }
22279
22280 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
22281         LDKChannelManagerReadArgs this_ptr_conv;
22282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22283         this_ptr_conv.is_owned = false;
22284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22285         // WARNING: This object doesn't live past this scope, needs clone!
22286         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
22287         return ret_ret;
22288 }
22289
22290 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
22291         LDKChannelManagerReadArgs this_ptr_conv;
22292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22293         this_ptr_conv.is_owned = false;
22294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22295         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22296         CHECK_ACCESS(val_ptr);
22297         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
22298         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
22299 }
22300
22301 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
22302         LDKChannelManagerReadArgs this_ptr_conv;
22303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22304         this_ptr_conv.is_owned = false;
22305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22306         // WARNING: This object doesn't live past this scope, needs clone!
22307         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
22308         return ret_ret;
22309 }
22310
22311 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
22312         LDKChannelManagerReadArgs this_ptr_conv;
22313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22314         this_ptr_conv.is_owned = false;
22315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22316         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22317         CHECK_ACCESS(val_ptr);
22318         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
22319         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
22320 }
22321
22322 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
22323         LDKChannelManagerReadArgs this_ptr_conv;
22324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22325         this_ptr_conv.is_owned = false;
22326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22327         // WARNING: This object doesn't live past this scope, needs clone!
22328         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
22329         return ret_ret;
22330 }
22331
22332 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
22333         LDKChannelManagerReadArgs this_ptr_conv;
22334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22335         this_ptr_conv.is_owned = false;
22336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22337         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22338         CHECK_ACCESS(val_ptr);
22339         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
22340         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
22341 }
22342
22343 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
22344         LDKChannelManagerReadArgs this_ptr_conv;
22345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22346         this_ptr_conv.is_owned = false;
22347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22348         // WARNING: This object doesn't live past this scope, needs clone!
22349         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
22350         return ret_ret;
22351 }
22352
22353 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
22354         LDKChannelManagerReadArgs this_ptr_conv;
22355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22356         this_ptr_conv.is_owned = false;
22357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22358         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22359         CHECK_ACCESS(val_ptr);
22360         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
22361         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
22362 }
22363
22364 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
22365         LDKChannelManagerReadArgs this_ptr_conv;
22366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22367         this_ptr_conv.is_owned = false;
22368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22369         // WARNING: This object doesn't live past this scope, needs clone!
22370         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
22371         return ret_ret;
22372 }
22373
22374 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
22375         LDKChannelManagerReadArgs this_ptr_conv;
22376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22377         this_ptr_conv.is_owned = false;
22378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22379         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22380         CHECK_ACCESS(val_ptr);
22381         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
22382         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
22383 }
22384
22385 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
22386         LDKChannelManagerReadArgs this_ptr_conv;
22387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22388         this_ptr_conv.is_owned = false;
22389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22390         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
22391         uint64_t ret_ref = 0;
22392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22395         ret_ref = (uint64_t)ret_var.inner;
22396         if (ret_var.is_owned) {
22397                 ret_ref |= 1;
22398         }
22399         return ret_ref;
22400 }
22401
22402 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
22403         LDKChannelManagerReadArgs this_ptr_conv;
22404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22405         this_ptr_conv.is_owned = false;
22406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22407         LDKUserConfig val_conv;
22408         val_conv.inner = (void*)(val & (~1));
22409         val_conv.is_owned = (val & 1) || (val == 0);
22410         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22411         val_conv = UserConfig_clone(&val_conv);
22412         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
22413 }
22414
22415 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(uint32_t keys_manager, uint32_t fee_estimator, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t default_config, uint32_tArray channel_monitors) {
22416         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
22417         CHECK_ACCESS(keys_manager_ptr);
22418         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
22419         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22420         CHECK_ACCESS(fee_estimator_ptr);
22421         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22422         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
22423         CHECK_ACCESS(chain_monitor_ptr);
22424         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
22425         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
22426         CHECK_ACCESS(tx_broadcaster_ptr);
22427         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
22428         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22429         CHECK_ACCESS(logger_ptr);
22430         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22431         LDKUserConfig default_config_conv;
22432         default_config_conv.inner = (void*)(default_config & (~1));
22433         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
22434         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
22435         default_config_conv = UserConfig_clone(&default_config_conv);
22436         LDKCVec_ChannelMonitorZ channel_monitors_constr;
22437         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
22438         if (channel_monitors_constr.datalen > 0)
22439                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22440         else
22441                 channel_monitors_constr.data = NULL;
22442         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
22443         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
22444                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
22445                 LDKChannelMonitor channel_monitors_conv_16_conv;
22446                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
22447                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
22448                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
22449                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
22450         }
22451         LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
22452         uint64_t ret_ref = 0;
22453         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22454         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22456         ret_ref = (uint64_t)ret_var.inner;
22457         if (ret_var.is_owned) {
22458                 ret_ref |= 1;
22459         }
22460         return ret_ref;
22461 }
22462
22463 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
22464         LDKu8slice ser_ref;
22465         ser_ref.datalen = *((uint32_t*)ser);
22466         ser_ref.data = (int8_t*)(ser + 4);
22467         LDKChannelManagerReadArgs arg_conv;
22468         arg_conv.inner = (void*)(arg & (~1));
22469         arg_conv.is_owned = (arg & 1) || (arg == 0);
22470         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22471         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
22472         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22473         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
22474         return (uint64_t)ret_conv;
22475 }
22476
22477 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_obj) {
22478         LDKDecodeError this_obj_conv;
22479         this_obj_conv.inner = (void*)(this_obj & (~1));
22480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22482         DecodeError_free(this_obj_conv);
22483 }
22484
22485 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
22486         LDKDecodeError ret_var = DecodeError_clone(arg);
22487 uint64_t ret_ref = 0;
22488 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22489 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22490 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22491 ret_ref = (uint64_t)ret_var.inner;
22492 if (ret_var.is_owned) {
22493         ret_ref |= 1;
22494 }
22495         return ret_ref;
22496 }
22497 int64_t  __attribute__((visibility("default"))) TS_DecodeError_clone_ptr(uint32_t arg) {
22498         LDKDecodeError arg_conv;
22499         arg_conv.inner = (void*)(arg & (~1));
22500         arg_conv.is_owned = false;
22501         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22502         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
22503         return ret_val;
22504 }
22505
22506 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
22507         LDKDecodeError orig_conv;
22508         orig_conv.inner = (void*)(orig & (~1));
22509         orig_conv.is_owned = false;
22510         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22511         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
22512         uint64_t ret_ref = 0;
22513         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22514         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22516         ret_ref = (uint64_t)ret_var.inner;
22517         if (ret_var.is_owned) {
22518                 ret_ref |= 1;
22519         }
22520         return ret_ref;
22521 }
22522
22523 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_obj) {
22524         LDKInit this_obj_conv;
22525         this_obj_conv.inner = (void*)(this_obj & (~1));
22526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22528         Init_free(this_obj_conv);
22529 }
22530
22531 uint32_t  __attribute__((visibility("default"))) TS_Init_get_features(uint32_t this_ptr) {
22532         LDKInit this_ptr_conv;
22533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22534         this_ptr_conv.is_owned = false;
22535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22536         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
22537         uint64_t ret_ref = 0;
22538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22541         ret_ref = (uint64_t)ret_var.inner;
22542         if (ret_var.is_owned) {
22543                 ret_ref |= 1;
22544         }
22545         return ret_ref;
22546 }
22547
22548 void  __attribute__((visibility("default"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
22549         LDKInit this_ptr_conv;
22550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22551         this_ptr_conv.is_owned = false;
22552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22553         LDKInitFeatures val_conv;
22554         val_conv.inner = (void*)(val & (~1));
22555         val_conv.is_owned = (val & 1) || (val == 0);
22556         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22557         val_conv = InitFeatures_clone(&val_conv);
22558         Init_set_features(&this_ptr_conv, val_conv);
22559 }
22560
22561 uint32_t  __attribute__((visibility("default"))) TS_Init_new(uint32_t features_arg) {
22562         LDKInitFeatures features_arg_conv;
22563         features_arg_conv.inner = (void*)(features_arg & (~1));
22564         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
22565         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
22566         features_arg_conv = InitFeatures_clone(&features_arg_conv);
22567         LDKInit ret_var = Init_new(features_arg_conv);
22568         uint64_t ret_ref = 0;
22569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22572         ret_ref = (uint64_t)ret_var.inner;
22573         if (ret_var.is_owned) {
22574                 ret_ref |= 1;
22575         }
22576         return ret_ref;
22577 }
22578
22579 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
22580         LDKInit ret_var = Init_clone(arg);
22581 uint64_t ret_ref = 0;
22582 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22583 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22584 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22585 ret_ref = (uint64_t)ret_var.inner;
22586 if (ret_var.is_owned) {
22587         ret_ref |= 1;
22588 }
22589         return ret_ref;
22590 }
22591 int64_t  __attribute__((visibility("default"))) TS_Init_clone_ptr(uint32_t arg) {
22592         LDKInit arg_conv;
22593         arg_conv.inner = (void*)(arg & (~1));
22594         arg_conv.is_owned = false;
22595         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22596         int64_t ret_val = Init_clone_ptr(&arg_conv);
22597         return ret_val;
22598 }
22599
22600 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
22601         LDKInit orig_conv;
22602         orig_conv.inner = (void*)(orig & (~1));
22603         orig_conv.is_owned = false;
22604         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22605         LDKInit ret_var = Init_clone(&orig_conv);
22606         uint64_t ret_ref = 0;
22607         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22608         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22610         ret_ref = (uint64_t)ret_var.inner;
22611         if (ret_var.is_owned) {
22612                 ret_ref |= 1;
22613         }
22614         return ret_ref;
22615 }
22616
22617 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_obj) {
22618         LDKErrorMessage this_obj_conv;
22619         this_obj_conv.inner = (void*)(this_obj & (~1));
22620         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22622         ErrorMessage_free(this_obj_conv);
22623 }
22624
22625 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
22626         LDKErrorMessage this_ptr_conv;
22627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22628         this_ptr_conv.is_owned = false;
22629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22630         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22631         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
22632         return ret_arr;
22633 }
22634
22635 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
22636         LDKErrorMessage this_ptr_conv;
22637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22638         this_ptr_conv.is_owned = false;
22639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22640         LDKThirtyTwoBytes val_ref;
22641         CHECK(*((uint32_t*)val) == 32);
22642         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22643         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
22644 }
22645
22646 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
22647         LDKErrorMessage this_ptr_conv;
22648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22649         this_ptr_conv.is_owned = false;
22650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22651         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
22652         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22653         Str_free(ret_str);
22654         return ret_conv;
22655 }
22656
22657 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
22658         LDKErrorMessage this_ptr_conv;
22659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22660         this_ptr_conv.is_owned = false;
22661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22662         LDKStr val_conv = str_ref_to_owned_c(val);
22663         ErrorMessage_set_data(&this_ptr_conv, val_conv);
22664 }
22665
22666 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
22667         LDKThirtyTwoBytes channel_id_arg_ref;
22668         CHECK(*((uint32_t*)channel_id_arg) == 32);
22669         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
22670         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
22671         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
22672         uint64_t ret_ref = 0;
22673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22676         ret_ref = (uint64_t)ret_var.inner;
22677         if (ret_var.is_owned) {
22678                 ret_ref |= 1;
22679         }
22680         return ret_ref;
22681 }
22682
22683 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
22684         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
22685 uint64_t ret_ref = 0;
22686 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22687 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22688 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22689 ret_ref = (uint64_t)ret_var.inner;
22690 if (ret_var.is_owned) {
22691         ret_ref |= 1;
22692 }
22693         return ret_ref;
22694 }
22695 int64_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
22696         LDKErrorMessage arg_conv;
22697         arg_conv.inner = (void*)(arg & (~1));
22698         arg_conv.is_owned = false;
22699         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22700         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
22701         return ret_val;
22702 }
22703
22704 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
22705         LDKErrorMessage orig_conv;
22706         orig_conv.inner = (void*)(orig & (~1));
22707         orig_conv.is_owned = false;
22708         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22709         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
22710         uint64_t ret_ref = 0;
22711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22714         ret_ref = (uint64_t)ret_var.inner;
22715         if (ret_var.is_owned) {
22716                 ret_ref |= 1;
22717         }
22718         return ret_ref;
22719 }
22720
22721 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_obj) {
22722         LDKPing this_obj_conv;
22723         this_obj_conv.inner = (void*)(this_obj & (~1));
22724         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22726         Ping_free(this_obj_conv);
22727 }
22728
22729 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
22730         LDKPing this_ptr_conv;
22731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22732         this_ptr_conv.is_owned = false;
22733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22734         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
22735         return ret_val;
22736 }
22737
22738 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
22739         LDKPing this_ptr_conv;
22740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22741         this_ptr_conv.is_owned = false;
22742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22743         Ping_set_ponglen(&this_ptr_conv, val);
22744 }
22745
22746 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
22747         LDKPing this_ptr_conv;
22748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22749         this_ptr_conv.is_owned = false;
22750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22751         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
22752         return ret_val;
22753 }
22754
22755 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
22756         LDKPing this_ptr_conv;
22757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22758         this_ptr_conv.is_owned = false;
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22760         Ping_set_byteslen(&this_ptr_conv, val);
22761 }
22762
22763 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
22764         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
22765         uint64_t ret_ref = 0;
22766         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22767         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22769         ret_ref = (uint64_t)ret_var.inner;
22770         if (ret_var.is_owned) {
22771                 ret_ref |= 1;
22772         }
22773         return ret_ref;
22774 }
22775
22776 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
22777         LDKPing ret_var = Ping_clone(arg);
22778 uint64_t ret_ref = 0;
22779 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22780 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22781 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22782 ret_ref = (uint64_t)ret_var.inner;
22783 if (ret_var.is_owned) {
22784         ret_ref |= 1;
22785 }
22786         return ret_ref;
22787 }
22788 int64_t  __attribute__((visibility("default"))) TS_Ping_clone_ptr(uint32_t arg) {
22789         LDKPing arg_conv;
22790         arg_conv.inner = (void*)(arg & (~1));
22791         arg_conv.is_owned = false;
22792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22793         int64_t ret_val = Ping_clone_ptr(&arg_conv);
22794         return ret_val;
22795 }
22796
22797 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
22798         LDKPing orig_conv;
22799         orig_conv.inner = (void*)(orig & (~1));
22800         orig_conv.is_owned = false;
22801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22802         LDKPing ret_var = Ping_clone(&orig_conv);
22803         uint64_t ret_ref = 0;
22804         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22805         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22807         ret_ref = (uint64_t)ret_var.inner;
22808         if (ret_var.is_owned) {
22809                 ret_ref |= 1;
22810         }
22811         return ret_ref;
22812 }
22813
22814 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_obj) {
22815         LDKPong this_obj_conv;
22816         this_obj_conv.inner = (void*)(this_obj & (~1));
22817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22819         Pong_free(this_obj_conv);
22820 }
22821
22822 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
22823         LDKPong this_ptr_conv;
22824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22825         this_ptr_conv.is_owned = false;
22826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22827         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
22828         return ret_val;
22829 }
22830
22831 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
22832         LDKPong this_ptr_conv;
22833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22834         this_ptr_conv.is_owned = false;
22835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22836         Pong_set_byteslen(&this_ptr_conv, val);
22837 }
22838
22839 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
22840         LDKPong ret_var = Pong_new(byteslen_arg);
22841         uint64_t ret_ref = 0;
22842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22845         ret_ref = (uint64_t)ret_var.inner;
22846         if (ret_var.is_owned) {
22847                 ret_ref |= 1;
22848         }
22849         return ret_ref;
22850 }
22851
22852 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
22853         LDKPong ret_var = Pong_clone(arg);
22854 uint64_t ret_ref = 0;
22855 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22856 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22857 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22858 ret_ref = (uint64_t)ret_var.inner;
22859 if (ret_var.is_owned) {
22860         ret_ref |= 1;
22861 }
22862         return ret_ref;
22863 }
22864 int64_t  __attribute__((visibility("default"))) TS_Pong_clone_ptr(uint32_t arg) {
22865         LDKPong arg_conv;
22866         arg_conv.inner = (void*)(arg & (~1));
22867         arg_conv.is_owned = false;
22868         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22869         int64_t ret_val = Pong_clone_ptr(&arg_conv);
22870         return ret_val;
22871 }
22872
22873 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
22874         LDKPong orig_conv;
22875         orig_conv.inner = (void*)(orig & (~1));
22876         orig_conv.is_owned = false;
22877         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22878         LDKPong ret_var = Pong_clone(&orig_conv);
22879         uint64_t ret_ref = 0;
22880         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22881         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22883         ret_ref = (uint64_t)ret_var.inner;
22884         if (ret_var.is_owned) {
22885                 ret_ref |= 1;
22886         }
22887         return ret_ref;
22888 }
22889
22890 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_obj) {
22891         LDKOpenChannel this_obj_conv;
22892         this_obj_conv.inner = (void*)(this_obj & (~1));
22893         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22895         OpenChannel_free(this_obj_conv);
22896 }
22897
22898 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
22899         LDKOpenChannel this_ptr_conv;
22900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22901         this_ptr_conv.is_owned = false;
22902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22903         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22904         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
22905         return ret_arr;
22906 }
22907
22908 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22909         LDKOpenChannel this_ptr_conv;
22910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22911         this_ptr_conv.is_owned = false;
22912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22913         LDKThirtyTwoBytes val_ref;
22914         CHECK(*((uint32_t*)val) == 32);
22915         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22916         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
22917 }
22918
22919 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
22920         LDKOpenChannel this_ptr_conv;
22921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22922         this_ptr_conv.is_owned = false;
22923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22924         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
22925         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
22926         return ret_arr;
22927 }
22928
22929 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
22930         LDKOpenChannel this_ptr_conv;
22931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22932         this_ptr_conv.is_owned = false;
22933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22934         LDKThirtyTwoBytes val_ref;
22935         CHECK(*((uint32_t*)val) == 32);
22936         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
22937         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22938 }
22939
22940 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
22941         LDKOpenChannel this_ptr_conv;
22942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22943         this_ptr_conv.is_owned = false;
22944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22945         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
22946         return ret_val;
22947 }
22948
22949 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
22950         LDKOpenChannel this_ptr_conv;
22951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22952         this_ptr_conv.is_owned = false;
22953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22954         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
22955 }
22956
22957 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
22958         LDKOpenChannel this_ptr_conv;
22959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22960         this_ptr_conv.is_owned = false;
22961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22962         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
22963         return ret_val;
22964 }
22965
22966 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
22967         LDKOpenChannel this_ptr_conv;
22968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22969         this_ptr_conv.is_owned = false;
22970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22971         OpenChannel_set_push_msat(&this_ptr_conv, val);
22972 }
22973
22974 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
22975         LDKOpenChannel this_ptr_conv;
22976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22977         this_ptr_conv.is_owned = false;
22978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22979         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
22980         return ret_val;
22981 }
22982
22983 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
22984         LDKOpenChannel this_ptr_conv;
22985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22986         this_ptr_conv.is_owned = false;
22987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22988         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22989 }
22990
22991 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
22992         LDKOpenChannel this_ptr_conv;
22993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22994         this_ptr_conv.is_owned = false;
22995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22996         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22997         return ret_val;
22998 }
22999
23000 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
23001         LDKOpenChannel this_ptr_conv;
23002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23003         this_ptr_conv.is_owned = false;
23004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23005         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
23006 }
23007
23008 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
23009         LDKOpenChannel this_ptr_conv;
23010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23011         this_ptr_conv.is_owned = false;
23012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23013         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
23014         return ret_val;
23015 }
23016
23017 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
23018         LDKOpenChannel this_ptr_conv;
23019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23020         this_ptr_conv.is_owned = false;
23021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23022         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
23023 }
23024
23025 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
23026         LDKOpenChannel this_ptr_conv;
23027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23028         this_ptr_conv.is_owned = false;
23029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23030         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
23031         return ret_val;
23032 }
23033
23034 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
23035         LDKOpenChannel this_ptr_conv;
23036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23037         this_ptr_conv.is_owned = false;
23038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23039         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
23040 }
23041
23042 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
23043         LDKOpenChannel this_ptr_conv;
23044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23045         this_ptr_conv.is_owned = false;
23046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23047         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
23048         return ret_val;
23049 }
23050
23051 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
23052         LDKOpenChannel this_ptr_conv;
23053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23054         this_ptr_conv.is_owned = false;
23055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23056         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
23057 }
23058
23059 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
23060         LDKOpenChannel this_ptr_conv;
23061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23062         this_ptr_conv.is_owned = false;
23063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23064         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
23065         return ret_val;
23066 }
23067
23068 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23069         LDKOpenChannel this_ptr_conv;
23070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23071         this_ptr_conv.is_owned = false;
23072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23073         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
23074 }
23075
23076 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
23077         LDKOpenChannel this_ptr_conv;
23078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23079         this_ptr_conv.is_owned = false;
23080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23081         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
23082         return ret_val;
23083 }
23084
23085 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
23086         LDKOpenChannel this_ptr_conv;
23087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23088         this_ptr_conv.is_owned = false;
23089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23090         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
23091 }
23092
23093 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
23094         LDKOpenChannel this_ptr_conv;
23095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23096         this_ptr_conv.is_owned = false;
23097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23098         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23099         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
23100         return ret_arr;
23101 }
23102
23103 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
23104         LDKOpenChannel this_ptr_conv;
23105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23106         this_ptr_conv.is_owned = false;
23107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23108         LDKPublicKey val_ref;
23109         CHECK(*((uint32_t*)val) == 33);
23110         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23111         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
23112 }
23113
23114 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
23115         LDKOpenChannel this_ptr_conv;
23116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23117         this_ptr_conv.is_owned = false;
23118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23119         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23120         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
23121         return ret_arr;
23122 }
23123
23124 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
23125         LDKOpenChannel this_ptr_conv;
23126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23127         this_ptr_conv.is_owned = false;
23128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23129         LDKPublicKey val_ref;
23130         CHECK(*((uint32_t*)val) == 33);
23131         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23132         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23133 }
23134
23135 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
23136         LDKOpenChannel this_ptr_conv;
23137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23138         this_ptr_conv.is_owned = false;
23139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23140         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23141         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23142         return ret_arr;
23143 }
23144
23145 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23146         LDKOpenChannel this_ptr_conv;
23147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23148         this_ptr_conv.is_owned = false;
23149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23150         LDKPublicKey val_ref;
23151         CHECK(*((uint32_t*)val) == 33);
23152         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23153         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
23154 }
23155
23156 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23157         LDKOpenChannel this_ptr_conv;
23158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23159         this_ptr_conv.is_owned = false;
23160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23161         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23162         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23163         return ret_arr;
23164 }
23165
23166 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23167         LDKOpenChannel this_ptr_conv;
23168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23169         this_ptr_conv.is_owned = false;
23170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23171         LDKPublicKey val_ref;
23172         CHECK(*((uint32_t*)val) == 33);
23173         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23174         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23175 }
23176
23177 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
23178         LDKOpenChannel this_ptr_conv;
23179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23180         this_ptr_conv.is_owned = false;
23181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23182         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23183         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23184         return ret_arr;
23185 }
23186
23187 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23188         LDKOpenChannel this_ptr_conv;
23189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23190         this_ptr_conv.is_owned = false;
23191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23192         LDKPublicKey val_ref;
23193         CHECK(*((uint32_t*)val) == 33);
23194         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23195         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23196 }
23197
23198 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23199         LDKOpenChannel this_ptr_conv;
23200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23201         this_ptr_conv.is_owned = false;
23202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23203         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23204         memcpy((uint8_t*)(ret_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23205         return ret_arr;
23206 }
23207
23208 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23209         LDKOpenChannel this_ptr_conv;
23210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23211         this_ptr_conv.is_owned = false;
23212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23213         LDKPublicKey val_ref;
23214         CHECK(*((uint32_t*)val) == 33);
23215         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23216         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23217 }
23218
23219 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
23220         LDKOpenChannel this_ptr_conv;
23221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23222         this_ptr_conv.is_owned = false;
23223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23224         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
23225         return ret_val;
23226 }
23227
23228 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
23229         LDKOpenChannel this_ptr_conv;
23230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23231         this_ptr_conv.is_owned = false;
23232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23233         OpenChannel_set_channel_flags(&this_ptr_conv, val);
23234 }
23235
23236 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
23237         LDKOpenChannel this_ptr_conv;
23238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23239         this_ptr_conv.is_owned = false;
23240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23241         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
23242         uint64_t ret_ref = 0;
23243         if ((uint64_t)ret_var.inner > 4096) {
23244                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23245                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23247                 ret_ref = (uint64_t)ret_var.inner;
23248                 if (ret_var.is_owned) {
23249                         ret_ref |= 1;
23250                 }
23251         }
23252         return ret_ref;
23253 }
23254
23255 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
23256         LDKOpenChannel this_ptr_conv;
23257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23258         this_ptr_conv.is_owned = false;
23259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23260         LDKChannelTypeFeatures val_conv;
23261         val_conv.inner = (void*)(val & (~1));
23262         val_conv.is_owned = (val & 1) || (val == 0);
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23264         val_conv = ChannelTypeFeatures_clone(&val_conv);
23265         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
23266 }
23267
23268 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
23269         LDKOpenChannel ret_var = OpenChannel_clone(arg);
23270 uint64_t ret_ref = 0;
23271 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23272 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23273 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23274 ret_ref = (uint64_t)ret_var.inner;
23275 if (ret_var.is_owned) {
23276         ret_ref |= 1;
23277 }
23278         return ret_ref;
23279 }
23280 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
23281         LDKOpenChannel arg_conv;
23282         arg_conv.inner = (void*)(arg & (~1));
23283         arg_conv.is_owned = false;
23284         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23285         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
23286         return ret_val;
23287 }
23288
23289 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
23290         LDKOpenChannel orig_conv;
23291         orig_conv.inner = (void*)(orig & (~1));
23292         orig_conv.is_owned = false;
23293         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23294         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
23295         uint64_t ret_ref = 0;
23296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23299         ret_ref = (uint64_t)ret_var.inner;
23300         if (ret_var.is_owned) {
23301                 ret_ref |= 1;
23302         }
23303         return ret_ref;
23304 }
23305
23306 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_obj) {
23307         LDKAcceptChannel this_obj_conv;
23308         this_obj_conv.inner = (void*)(this_obj & (~1));
23309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23311         AcceptChannel_free(this_obj_conv);
23312 }
23313
23314 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
23315         LDKAcceptChannel this_ptr_conv;
23316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23317         this_ptr_conv.is_owned = false;
23318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23319         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23320         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
23321         return ret_arr;
23322 }
23323
23324 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23325         LDKAcceptChannel this_ptr_conv;
23326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23327         this_ptr_conv.is_owned = false;
23328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23329         LDKThirtyTwoBytes val_ref;
23330         CHECK(*((uint32_t*)val) == 32);
23331         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23332         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
23333 }
23334
23335 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
23336         LDKAcceptChannel this_ptr_conv;
23337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23338         this_ptr_conv.is_owned = false;
23339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23340         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
23341         return ret_val;
23342 }
23343
23344 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
23345         LDKAcceptChannel this_ptr_conv;
23346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23347         this_ptr_conv.is_owned = false;
23348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23349         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
23350 }
23351
23352 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
23353         LDKAcceptChannel this_ptr_conv;
23354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23355         this_ptr_conv.is_owned = false;
23356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23357         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
23358         return ret_val;
23359 }
23360
23361 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
23362         LDKAcceptChannel this_ptr_conv;
23363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23364         this_ptr_conv.is_owned = false;
23365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23366         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
23367 }
23368
23369 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
23370         LDKAcceptChannel this_ptr_conv;
23371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23372         this_ptr_conv.is_owned = false;
23373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23374         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
23375         return ret_val;
23376 }
23377
23378 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
23379         LDKAcceptChannel this_ptr_conv;
23380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23381         this_ptr_conv.is_owned = false;
23382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23383         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
23384 }
23385
23386 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
23387         LDKAcceptChannel this_ptr_conv;
23388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23389         this_ptr_conv.is_owned = false;
23390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23391         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
23392         return ret_val;
23393 }
23394
23395 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
23396         LDKAcceptChannel this_ptr_conv;
23397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23398         this_ptr_conv.is_owned = false;
23399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23400         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
23401 }
23402
23403 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
23404         LDKAcceptChannel this_ptr_conv;
23405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23406         this_ptr_conv.is_owned = false;
23407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23408         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
23409         return ret_val;
23410 }
23411
23412 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
23413         LDKAcceptChannel this_ptr_conv;
23414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23415         this_ptr_conv.is_owned = false;
23416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23417         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
23418 }
23419
23420 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
23421         LDKAcceptChannel this_ptr_conv;
23422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23423         this_ptr_conv.is_owned = false;
23424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23425         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
23426         return ret_val;
23427 }
23428
23429 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23430         LDKAcceptChannel this_ptr_conv;
23431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23432         this_ptr_conv.is_owned = false;
23433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23434         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
23435 }
23436
23437 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
23438         LDKAcceptChannel this_ptr_conv;
23439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23440         this_ptr_conv.is_owned = false;
23441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23442         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
23443         return ret_val;
23444 }
23445
23446 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
23447         LDKAcceptChannel this_ptr_conv;
23448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23449         this_ptr_conv.is_owned = false;
23450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23451         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
23452 }
23453
23454 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
23455         LDKAcceptChannel this_ptr_conv;
23456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23457         this_ptr_conv.is_owned = false;
23458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23459         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23460         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
23461         return ret_arr;
23462 }
23463
23464 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
23465         LDKAcceptChannel this_ptr_conv;
23466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23467         this_ptr_conv.is_owned = false;
23468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23469         LDKPublicKey val_ref;
23470         CHECK(*((uint32_t*)val) == 33);
23471         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23472         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
23473 }
23474
23475 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
23476         LDKAcceptChannel this_ptr_conv;
23477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23478         this_ptr_conv.is_owned = false;
23479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23480         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23481         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
23482         return ret_arr;
23483 }
23484
23485 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
23486         LDKAcceptChannel this_ptr_conv;
23487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23488         this_ptr_conv.is_owned = false;
23489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23490         LDKPublicKey val_ref;
23491         CHECK(*((uint32_t*)val) == 33);
23492         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23493         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23494 }
23495
23496 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
23497         LDKAcceptChannel this_ptr_conv;
23498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23499         this_ptr_conv.is_owned = false;
23500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23501         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23502         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23503         return ret_arr;
23504 }
23505
23506 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23507         LDKAcceptChannel this_ptr_conv;
23508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23509         this_ptr_conv.is_owned = false;
23510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23511         LDKPublicKey val_ref;
23512         CHECK(*((uint32_t*)val) == 33);
23513         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23514         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
23515 }
23516
23517 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23518         LDKAcceptChannel this_ptr_conv;
23519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23520         this_ptr_conv.is_owned = false;
23521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23522         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23523         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23524         return ret_arr;
23525 }
23526
23527 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23528         LDKAcceptChannel this_ptr_conv;
23529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23530         this_ptr_conv.is_owned = false;
23531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23532         LDKPublicKey val_ref;
23533         CHECK(*((uint32_t*)val) == 33);
23534         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23535         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23536 }
23537
23538 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
23539         LDKAcceptChannel this_ptr_conv;
23540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23541         this_ptr_conv.is_owned = false;
23542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23543         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23544         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23545         return ret_arr;
23546 }
23547
23548 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23549         LDKAcceptChannel this_ptr_conv;
23550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23551         this_ptr_conv.is_owned = false;
23552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23553         LDKPublicKey val_ref;
23554         CHECK(*((uint32_t*)val) == 33);
23555         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23556         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23557 }
23558
23559 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23560         LDKAcceptChannel this_ptr_conv;
23561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23562         this_ptr_conv.is_owned = false;
23563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23564         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23565         memcpy((uint8_t*)(ret_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23566         return ret_arr;
23567 }
23568
23569 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23570         LDKAcceptChannel this_ptr_conv;
23571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23572         this_ptr_conv.is_owned = false;
23573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23574         LDKPublicKey val_ref;
23575         CHECK(*((uint32_t*)val) == 33);
23576         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23577         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23578 }
23579
23580 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
23581         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
23582 uint64_t ret_ref = 0;
23583 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23584 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23585 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23586 ret_ref = (uint64_t)ret_var.inner;
23587 if (ret_var.is_owned) {
23588         ret_ref |= 1;
23589 }
23590         return ret_ref;
23591 }
23592 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
23593         LDKAcceptChannel arg_conv;
23594         arg_conv.inner = (void*)(arg & (~1));
23595         arg_conv.is_owned = false;
23596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23597         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
23598         return ret_val;
23599 }
23600
23601 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
23602         LDKAcceptChannel orig_conv;
23603         orig_conv.inner = (void*)(orig & (~1));
23604         orig_conv.is_owned = false;
23605         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23606         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
23607         uint64_t ret_ref = 0;
23608         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23609         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23611         ret_ref = (uint64_t)ret_var.inner;
23612         if (ret_var.is_owned) {
23613                 ret_ref |= 1;
23614         }
23615         return ret_ref;
23616 }
23617
23618 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_obj) {
23619         LDKFundingCreated this_obj_conv;
23620         this_obj_conv.inner = (void*)(this_obj & (~1));
23621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23623         FundingCreated_free(this_obj_conv);
23624 }
23625
23626 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
23627         LDKFundingCreated this_ptr_conv;
23628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23629         this_ptr_conv.is_owned = false;
23630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23631         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23632         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
23633         return ret_arr;
23634 }
23635
23636 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23637         LDKFundingCreated this_ptr_conv;
23638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23639         this_ptr_conv.is_owned = false;
23640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23641         LDKThirtyTwoBytes val_ref;
23642         CHECK(*((uint32_t*)val) == 32);
23643         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23644         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
23645 }
23646
23647 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
23648         LDKFundingCreated this_ptr_conv;
23649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23650         this_ptr_conv.is_owned = false;
23651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23652         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23653         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
23654         return ret_arr;
23655 }
23656
23657 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
23658         LDKFundingCreated this_ptr_conv;
23659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23660         this_ptr_conv.is_owned = false;
23661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23662         LDKThirtyTwoBytes val_ref;
23663         CHECK(*((uint32_t*)val) == 32);
23664         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23665         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
23666 }
23667
23668 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
23669         LDKFundingCreated this_ptr_conv;
23670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23671         this_ptr_conv.is_owned = false;
23672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23673         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
23674         return ret_val;
23675 }
23676
23677 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
23678         LDKFundingCreated this_ptr_conv;
23679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23680         this_ptr_conv.is_owned = false;
23681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23682         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
23683 }
23684
23685 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
23686         LDKFundingCreated this_ptr_conv;
23687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23688         this_ptr_conv.is_owned = false;
23689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23690         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23691         memcpy((uint8_t*)(ret_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
23692         return ret_arr;
23693 }
23694
23695 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
23696         LDKFundingCreated this_ptr_conv;
23697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23698         this_ptr_conv.is_owned = false;
23699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23700         LDKSignature val_ref;
23701         CHECK(*((uint32_t*)val) == 64);
23702         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
23703         FundingCreated_set_signature(&this_ptr_conv, val_ref);
23704 }
23705
23706 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_new(int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
23707         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
23708         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
23709         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
23710         LDKThirtyTwoBytes funding_txid_arg_ref;
23711         CHECK(*((uint32_t*)funding_txid_arg) == 32);
23712         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
23713         LDKSignature signature_arg_ref;
23714         CHECK(*((uint32_t*)signature_arg) == 64);
23715         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
23716         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
23717         uint64_t ret_ref = 0;
23718         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23719         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23721         ret_ref = (uint64_t)ret_var.inner;
23722         if (ret_var.is_owned) {
23723                 ret_ref |= 1;
23724         }
23725         return ret_ref;
23726 }
23727
23728 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
23729         LDKFundingCreated ret_var = FundingCreated_clone(arg);
23730 uint64_t ret_ref = 0;
23731 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23732 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23733 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23734 ret_ref = (uint64_t)ret_var.inner;
23735 if (ret_var.is_owned) {
23736         ret_ref |= 1;
23737 }
23738         return ret_ref;
23739 }
23740 int64_t  __attribute__((visibility("default"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
23741         LDKFundingCreated arg_conv;
23742         arg_conv.inner = (void*)(arg & (~1));
23743         arg_conv.is_owned = false;
23744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23745         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
23746         return ret_val;
23747 }
23748
23749 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
23750         LDKFundingCreated orig_conv;
23751         orig_conv.inner = (void*)(orig & (~1));
23752         orig_conv.is_owned = false;
23753         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23754         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
23755         uint64_t ret_ref = 0;
23756         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23757         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23759         ret_ref = (uint64_t)ret_var.inner;
23760         if (ret_var.is_owned) {
23761                 ret_ref |= 1;
23762         }
23763         return ret_ref;
23764 }
23765
23766 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_obj) {
23767         LDKFundingSigned this_obj_conv;
23768         this_obj_conv.inner = (void*)(this_obj & (~1));
23769         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23771         FundingSigned_free(this_obj_conv);
23772 }
23773
23774 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
23775         LDKFundingSigned this_ptr_conv;
23776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23777         this_ptr_conv.is_owned = false;
23778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23779         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23780         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
23781         return ret_arr;
23782 }
23783
23784 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23785         LDKFundingSigned this_ptr_conv;
23786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23787         this_ptr_conv.is_owned = false;
23788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23789         LDKThirtyTwoBytes val_ref;
23790         CHECK(*((uint32_t*)val) == 32);
23791         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23792         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
23793 }
23794
23795 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
23796         LDKFundingSigned this_ptr_conv;
23797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23798         this_ptr_conv.is_owned = false;
23799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23800         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
23801         memcpy((uint8_t*)(ret_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
23802         return ret_arr;
23803 }
23804
23805 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
23806         LDKFundingSigned this_ptr_conv;
23807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23808         this_ptr_conv.is_owned = false;
23809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23810         LDKSignature val_ref;
23811         CHECK(*((uint32_t*)val) == 64);
23812         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
23813         FundingSigned_set_signature(&this_ptr_conv, val_ref);
23814 }
23815
23816 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
23817         LDKThirtyTwoBytes channel_id_arg_ref;
23818         CHECK(*((uint32_t*)channel_id_arg) == 32);
23819         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23820         LDKSignature signature_arg_ref;
23821         CHECK(*((uint32_t*)signature_arg) == 64);
23822         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
23823         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
23824         uint64_t ret_ref = 0;
23825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23828         ret_ref = (uint64_t)ret_var.inner;
23829         if (ret_var.is_owned) {
23830                 ret_ref |= 1;
23831         }
23832         return ret_ref;
23833 }
23834
23835 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
23836         LDKFundingSigned ret_var = FundingSigned_clone(arg);
23837 uint64_t ret_ref = 0;
23838 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23839 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23840 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23841 ret_ref = (uint64_t)ret_var.inner;
23842 if (ret_var.is_owned) {
23843         ret_ref |= 1;
23844 }
23845         return ret_ref;
23846 }
23847 int64_t  __attribute__((visibility("default"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
23848         LDKFundingSigned arg_conv;
23849         arg_conv.inner = (void*)(arg & (~1));
23850         arg_conv.is_owned = false;
23851         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23852         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
23853         return ret_val;
23854 }
23855
23856 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
23857         LDKFundingSigned orig_conv;
23858         orig_conv.inner = (void*)(orig & (~1));
23859         orig_conv.is_owned = false;
23860         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23861         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
23862         uint64_t ret_ref = 0;
23863         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23864         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23866         ret_ref = (uint64_t)ret_var.inner;
23867         if (ret_var.is_owned) {
23868                 ret_ref |= 1;
23869         }
23870         return ret_ref;
23871 }
23872
23873 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_obj) {
23874         LDKFundingLocked this_obj_conv;
23875         this_obj_conv.inner = (void*)(this_obj & (~1));
23876         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23878         FundingLocked_free(this_obj_conv);
23879 }
23880
23881 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
23882         LDKFundingLocked this_ptr_conv;
23883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23884         this_ptr_conv.is_owned = false;
23885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23886         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23887         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
23888         return ret_arr;
23889 }
23890
23891 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23892         LDKFundingLocked this_ptr_conv;
23893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23894         this_ptr_conv.is_owned = false;
23895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23896         LDKThirtyTwoBytes val_ref;
23897         CHECK(*((uint32_t*)val) == 32);
23898         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
23899         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
23900 }
23901
23902 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
23903         LDKFundingLocked this_ptr_conv;
23904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23905         this_ptr_conv.is_owned = false;
23906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23907         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
23908         memcpy((uint8_t*)(ret_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23909         return ret_arr;
23910 }
23911
23912 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23913         LDKFundingLocked this_ptr_conv;
23914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23915         this_ptr_conv.is_owned = false;
23916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23917         LDKPublicKey val_ref;
23918         CHECK(*((uint32_t*)val) == 33);
23919         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
23920         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23921 }
23922
23923 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
23924         LDKThirtyTwoBytes channel_id_arg_ref;
23925         CHECK(*((uint32_t*)channel_id_arg) == 32);
23926         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
23927         LDKPublicKey next_per_commitment_point_arg_ref;
23928         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
23929         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
23930         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
23931         uint64_t ret_ref = 0;
23932         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23933         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23935         ret_ref = (uint64_t)ret_var.inner;
23936         if (ret_var.is_owned) {
23937                 ret_ref |= 1;
23938         }
23939         return ret_ref;
23940 }
23941
23942 static inline uint64_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
23943         LDKFundingLocked ret_var = FundingLocked_clone(arg);
23944 uint64_t ret_ref = 0;
23945 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23946 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23947 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23948 ret_ref = (uint64_t)ret_var.inner;
23949 if (ret_var.is_owned) {
23950         ret_ref |= 1;
23951 }
23952         return ret_ref;
23953 }
23954 int64_t  __attribute__((visibility("default"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
23955         LDKFundingLocked arg_conv;
23956         arg_conv.inner = (void*)(arg & (~1));
23957         arg_conv.is_owned = false;
23958         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23959         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
23960         return ret_val;
23961 }
23962
23963 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
23964         LDKFundingLocked orig_conv;
23965         orig_conv.inner = (void*)(orig & (~1));
23966         orig_conv.is_owned = false;
23967         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23968         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
23969         uint64_t ret_ref = 0;
23970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23973         ret_ref = (uint64_t)ret_var.inner;
23974         if (ret_var.is_owned) {
23975                 ret_ref |= 1;
23976         }
23977         return ret_ref;
23978 }
23979
23980 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_obj) {
23981         LDKShutdown this_obj_conv;
23982         this_obj_conv.inner = (void*)(this_obj & (~1));
23983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23985         Shutdown_free(this_obj_conv);
23986 }
23987
23988 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
23989         LDKShutdown this_ptr_conv;
23990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23991         this_ptr_conv.is_owned = false;
23992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23993         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
23994         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
23995         return ret_arr;
23996 }
23997
23998 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23999         LDKShutdown this_ptr_conv;
24000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24001         this_ptr_conv.is_owned = false;
24002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24003         LDKThirtyTwoBytes val_ref;
24004         CHECK(*((uint32_t*)val) == 32);
24005         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24006         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
24007 }
24008
24009 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
24010         LDKShutdown this_ptr_conv;
24011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24012         this_ptr_conv.is_owned = false;
24013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24014         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
24015         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
24016         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
24017         return ret_arr;
24018 }
24019
24020 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
24021         LDKShutdown this_ptr_conv;
24022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24023         this_ptr_conv.is_owned = false;
24024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24025         LDKCVec_u8Z val_ref;
24026         val_ref.datalen = *((uint32_t*)val);
24027         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
24028         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
24029         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
24030 }
24031
24032 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
24033         LDKThirtyTwoBytes channel_id_arg_ref;
24034         CHECK(*((uint32_t*)channel_id_arg) == 32);
24035         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24036         LDKCVec_u8Z scriptpubkey_arg_ref;
24037         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
24038         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
24039         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
24040         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
24041         uint64_t ret_ref = 0;
24042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24045         ret_ref = (uint64_t)ret_var.inner;
24046         if (ret_var.is_owned) {
24047                 ret_ref |= 1;
24048         }
24049         return ret_ref;
24050 }
24051
24052 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
24053         LDKShutdown ret_var = Shutdown_clone(arg);
24054 uint64_t ret_ref = 0;
24055 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24056 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24057 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24058 ret_ref = (uint64_t)ret_var.inner;
24059 if (ret_var.is_owned) {
24060         ret_ref |= 1;
24061 }
24062         return ret_ref;
24063 }
24064 int64_t  __attribute__((visibility("default"))) TS_Shutdown_clone_ptr(uint32_t arg) {
24065         LDKShutdown arg_conv;
24066         arg_conv.inner = (void*)(arg & (~1));
24067         arg_conv.is_owned = false;
24068         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24069         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
24070         return ret_val;
24071 }
24072
24073 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
24074         LDKShutdown orig_conv;
24075         orig_conv.inner = (void*)(orig & (~1));
24076         orig_conv.is_owned = false;
24077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24078         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
24079         uint64_t ret_ref = 0;
24080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24083         ret_ref = (uint64_t)ret_var.inner;
24084         if (ret_var.is_owned) {
24085                 ret_ref |= 1;
24086         }
24087         return ret_ref;
24088 }
24089
24090 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
24091         LDKClosingSignedFeeRange this_obj_conv;
24092         this_obj_conv.inner = (void*)(this_obj & (~1));
24093         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24095         ClosingSignedFeeRange_free(this_obj_conv);
24096 }
24097
24098 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
24099         LDKClosingSignedFeeRange this_ptr_conv;
24100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24101         this_ptr_conv.is_owned = false;
24102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24103         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
24104         return ret_val;
24105 }
24106
24107 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
24108         LDKClosingSignedFeeRange this_ptr_conv;
24109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24110         this_ptr_conv.is_owned = false;
24111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24112         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
24113 }
24114
24115 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
24116         LDKClosingSignedFeeRange this_ptr_conv;
24117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24118         this_ptr_conv.is_owned = false;
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24120         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
24121         return ret_val;
24122 }
24123
24124 void  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
24125         LDKClosingSignedFeeRange this_ptr_conv;
24126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24127         this_ptr_conv.is_owned = false;
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24129         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
24130 }
24131
24132 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
24133         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
24134         uint64_t ret_ref = 0;
24135         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24136         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24138         ret_ref = (uint64_t)ret_var.inner;
24139         if (ret_var.is_owned) {
24140                 ret_ref |= 1;
24141         }
24142         return ret_ref;
24143 }
24144
24145 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
24146         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
24147 uint64_t ret_ref = 0;
24148 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24149 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24150 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24151 ret_ref = (uint64_t)ret_var.inner;
24152 if (ret_var.is_owned) {
24153         ret_ref |= 1;
24154 }
24155         return ret_ref;
24156 }
24157 int64_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
24158         LDKClosingSignedFeeRange arg_conv;
24159         arg_conv.inner = (void*)(arg & (~1));
24160         arg_conv.is_owned = false;
24161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24162         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
24163         return ret_val;
24164 }
24165
24166 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
24167         LDKClosingSignedFeeRange orig_conv;
24168         orig_conv.inner = (void*)(orig & (~1));
24169         orig_conv.is_owned = false;
24170         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24171         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
24172         uint64_t ret_ref = 0;
24173         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24174         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24176         ret_ref = (uint64_t)ret_var.inner;
24177         if (ret_var.is_owned) {
24178                 ret_ref |= 1;
24179         }
24180         return ret_ref;
24181 }
24182
24183 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_obj) {
24184         LDKClosingSigned this_obj_conv;
24185         this_obj_conv.inner = (void*)(this_obj & (~1));
24186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24188         ClosingSigned_free(this_obj_conv);
24189 }
24190
24191 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
24192         LDKClosingSigned this_ptr_conv;
24193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24194         this_ptr_conv.is_owned = false;
24195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24196         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24197         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
24198         return ret_arr;
24199 }
24200
24201 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24202         LDKClosingSigned this_ptr_conv;
24203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24204         this_ptr_conv.is_owned = false;
24205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24206         LDKThirtyTwoBytes val_ref;
24207         CHECK(*((uint32_t*)val) == 32);
24208         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24209         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
24210 }
24211
24212 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
24213         LDKClosingSigned this_ptr_conv;
24214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24215         this_ptr_conv.is_owned = false;
24216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24217         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
24218         return ret_val;
24219 }
24220
24221 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
24222         LDKClosingSigned this_ptr_conv;
24223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24224         this_ptr_conv.is_owned = false;
24225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24226         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
24227 }
24228
24229 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
24230         LDKClosingSigned this_ptr_conv;
24231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24232         this_ptr_conv.is_owned = false;
24233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24234         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
24235         memcpy((uint8_t*)(ret_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
24236         return ret_arr;
24237 }
24238
24239 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24240         LDKClosingSigned this_ptr_conv;
24241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24242         this_ptr_conv.is_owned = false;
24243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24244         LDKSignature val_ref;
24245         CHECK(*((uint32_t*)val) == 64);
24246         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
24247         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
24248 }
24249
24250 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
24251         LDKClosingSigned this_ptr_conv;
24252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24253         this_ptr_conv.is_owned = false;
24254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24255         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
24256         uint64_t ret_ref = 0;
24257         if ((uint64_t)ret_var.inner > 4096) {
24258                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24259                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24261                 ret_ref = (uint64_t)ret_var.inner;
24262                 if (ret_var.is_owned) {
24263                         ret_ref |= 1;
24264                 }
24265         }
24266         return ret_ref;
24267 }
24268
24269 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
24270         LDKClosingSigned this_ptr_conv;
24271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24272         this_ptr_conv.is_owned = false;
24273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24274         LDKClosingSignedFeeRange val_conv;
24275         val_conv.inner = (void*)(val & (~1));
24276         val_conv.is_owned = (val & 1) || (val == 0);
24277         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24278         val_conv = ClosingSignedFeeRange_clone(&val_conv);
24279         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
24280 }
24281
24282 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg, uint32_t fee_range_arg) {
24283         LDKThirtyTwoBytes channel_id_arg_ref;
24284         CHECK(*((uint32_t*)channel_id_arg) == 32);
24285         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24286         LDKSignature signature_arg_ref;
24287         CHECK(*((uint32_t*)signature_arg) == 64);
24288         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
24289         LDKClosingSignedFeeRange fee_range_arg_conv;
24290         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
24291         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
24292         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
24293         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
24294         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
24295         uint64_t ret_ref = 0;
24296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24299         ret_ref = (uint64_t)ret_var.inner;
24300         if (ret_var.is_owned) {
24301                 ret_ref |= 1;
24302         }
24303         return ret_ref;
24304 }
24305
24306 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
24307         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
24308 uint64_t ret_ref = 0;
24309 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24310 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24311 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24312 ret_ref = (uint64_t)ret_var.inner;
24313 if (ret_var.is_owned) {
24314         ret_ref |= 1;
24315 }
24316         return ret_ref;
24317 }
24318 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
24319         LDKClosingSigned arg_conv;
24320         arg_conv.inner = (void*)(arg & (~1));
24321         arg_conv.is_owned = false;
24322         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24323         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
24324         return ret_val;
24325 }
24326
24327 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
24328         LDKClosingSigned orig_conv;
24329         orig_conv.inner = (void*)(orig & (~1));
24330         orig_conv.is_owned = false;
24331         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24332         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
24333         uint64_t ret_ref = 0;
24334         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24335         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24337         ret_ref = (uint64_t)ret_var.inner;
24338         if (ret_var.is_owned) {
24339                 ret_ref |= 1;
24340         }
24341         return ret_ref;
24342 }
24343
24344 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
24345         LDKUpdateAddHTLC this_obj_conv;
24346         this_obj_conv.inner = (void*)(this_obj & (~1));
24347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24349         UpdateAddHTLC_free(this_obj_conv);
24350 }
24351
24352 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
24353         LDKUpdateAddHTLC this_ptr_conv;
24354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24355         this_ptr_conv.is_owned = false;
24356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24357         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24358         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
24359         return ret_arr;
24360 }
24361
24362 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24363         LDKUpdateAddHTLC this_ptr_conv;
24364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24365         this_ptr_conv.is_owned = false;
24366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24367         LDKThirtyTwoBytes val_ref;
24368         CHECK(*((uint32_t*)val) == 32);
24369         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24370         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
24371 }
24372
24373 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
24374         LDKUpdateAddHTLC this_ptr_conv;
24375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24376         this_ptr_conv.is_owned = false;
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24378         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
24379         return ret_val;
24380 }
24381
24382 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24383         LDKUpdateAddHTLC this_ptr_conv;
24384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24385         this_ptr_conv.is_owned = false;
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24387         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
24388 }
24389
24390 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
24391         LDKUpdateAddHTLC this_ptr_conv;
24392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24393         this_ptr_conv.is_owned = false;
24394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24395         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
24396         return ret_val;
24397 }
24398
24399 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
24400         LDKUpdateAddHTLC this_ptr_conv;
24401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24402         this_ptr_conv.is_owned = false;
24403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24404         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
24405 }
24406
24407 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
24408         LDKUpdateAddHTLC this_ptr_conv;
24409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24410         this_ptr_conv.is_owned = false;
24411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24412         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24413         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
24414         return ret_arr;
24415 }
24416
24417 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
24418         LDKUpdateAddHTLC this_ptr_conv;
24419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24420         this_ptr_conv.is_owned = false;
24421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24422         LDKThirtyTwoBytes val_ref;
24423         CHECK(*((uint32_t*)val) == 32);
24424         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24425         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
24426 }
24427
24428 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
24429         LDKUpdateAddHTLC this_ptr_conv;
24430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24431         this_ptr_conv.is_owned = false;
24432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24433         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
24434         return ret_val;
24435 }
24436
24437 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
24438         LDKUpdateAddHTLC this_ptr_conv;
24439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24440         this_ptr_conv.is_owned = false;
24441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24442         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
24443 }
24444
24445 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
24446         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
24447 uint64_t ret_ref = 0;
24448 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24449 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24450 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24451 ret_ref = (uint64_t)ret_var.inner;
24452 if (ret_var.is_owned) {
24453         ret_ref |= 1;
24454 }
24455         return ret_ref;
24456 }
24457 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
24458         LDKUpdateAddHTLC arg_conv;
24459         arg_conv.inner = (void*)(arg & (~1));
24460         arg_conv.is_owned = false;
24461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24462         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
24463         return ret_val;
24464 }
24465
24466 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
24467         LDKUpdateAddHTLC orig_conv;
24468         orig_conv.inner = (void*)(orig & (~1));
24469         orig_conv.is_owned = false;
24470         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24471         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
24472         uint64_t ret_ref = 0;
24473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24476         ret_ref = (uint64_t)ret_var.inner;
24477         if (ret_var.is_owned) {
24478                 ret_ref |= 1;
24479         }
24480         return ret_ref;
24481 }
24482
24483 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
24484         LDKUpdateFulfillHTLC this_obj_conv;
24485         this_obj_conv.inner = (void*)(this_obj & (~1));
24486         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24488         UpdateFulfillHTLC_free(this_obj_conv);
24489 }
24490
24491 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
24492         LDKUpdateFulfillHTLC this_ptr_conv;
24493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24494         this_ptr_conv.is_owned = false;
24495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24496         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24497         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
24498         return ret_arr;
24499 }
24500
24501 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24502         LDKUpdateFulfillHTLC this_ptr_conv;
24503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24504         this_ptr_conv.is_owned = false;
24505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24506         LDKThirtyTwoBytes val_ref;
24507         CHECK(*((uint32_t*)val) == 32);
24508         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24509         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
24510 }
24511
24512 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
24513         LDKUpdateFulfillHTLC this_ptr_conv;
24514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24515         this_ptr_conv.is_owned = false;
24516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24517         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
24518         return ret_val;
24519 }
24520
24521 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24522         LDKUpdateFulfillHTLC this_ptr_conv;
24523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24524         this_ptr_conv.is_owned = false;
24525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24526         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
24527 }
24528
24529 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
24530         LDKUpdateFulfillHTLC this_ptr_conv;
24531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24532         this_ptr_conv.is_owned = false;
24533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24534         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24535         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
24536         return ret_arr;
24537 }
24538
24539 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
24540         LDKUpdateFulfillHTLC this_ptr_conv;
24541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24542         this_ptr_conv.is_owned = false;
24543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24544         LDKThirtyTwoBytes val_ref;
24545         CHECK(*((uint32_t*)val) == 32);
24546         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24547         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
24548 }
24549
24550 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
24551         LDKThirtyTwoBytes channel_id_arg_ref;
24552         CHECK(*((uint32_t*)channel_id_arg) == 32);
24553         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24554         LDKThirtyTwoBytes payment_preimage_arg_ref;
24555         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
24556         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
24557         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
24558         uint64_t ret_ref = 0;
24559         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24560         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24562         ret_ref = (uint64_t)ret_var.inner;
24563         if (ret_var.is_owned) {
24564                 ret_ref |= 1;
24565         }
24566         return ret_ref;
24567 }
24568
24569 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
24570         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
24571 uint64_t ret_ref = 0;
24572 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24573 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24574 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24575 ret_ref = (uint64_t)ret_var.inner;
24576 if (ret_var.is_owned) {
24577         ret_ref |= 1;
24578 }
24579         return ret_ref;
24580 }
24581 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
24582         LDKUpdateFulfillHTLC arg_conv;
24583         arg_conv.inner = (void*)(arg & (~1));
24584         arg_conv.is_owned = false;
24585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24586         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
24587         return ret_val;
24588 }
24589
24590 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
24591         LDKUpdateFulfillHTLC orig_conv;
24592         orig_conv.inner = (void*)(orig & (~1));
24593         orig_conv.is_owned = false;
24594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24595         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
24596         uint64_t ret_ref = 0;
24597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24600         ret_ref = (uint64_t)ret_var.inner;
24601         if (ret_var.is_owned) {
24602                 ret_ref |= 1;
24603         }
24604         return ret_ref;
24605 }
24606
24607 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
24608         LDKUpdateFailHTLC this_obj_conv;
24609         this_obj_conv.inner = (void*)(this_obj & (~1));
24610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24612         UpdateFailHTLC_free(this_obj_conv);
24613 }
24614
24615 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
24616         LDKUpdateFailHTLC this_ptr_conv;
24617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24618         this_ptr_conv.is_owned = false;
24619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24620         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24621         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
24622         return ret_arr;
24623 }
24624
24625 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24626         LDKUpdateFailHTLC this_ptr_conv;
24627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24628         this_ptr_conv.is_owned = false;
24629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24630         LDKThirtyTwoBytes val_ref;
24631         CHECK(*((uint32_t*)val) == 32);
24632         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24633         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
24634 }
24635
24636 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
24637         LDKUpdateFailHTLC this_ptr_conv;
24638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24639         this_ptr_conv.is_owned = false;
24640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24641         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
24642         return ret_val;
24643 }
24644
24645 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24646         LDKUpdateFailHTLC this_ptr_conv;
24647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24648         this_ptr_conv.is_owned = false;
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24650         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
24651 }
24652
24653 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
24654         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
24655 uint64_t ret_ref = 0;
24656 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24657 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24658 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24659 ret_ref = (uint64_t)ret_var.inner;
24660 if (ret_var.is_owned) {
24661         ret_ref |= 1;
24662 }
24663         return ret_ref;
24664 }
24665 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
24666         LDKUpdateFailHTLC arg_conv;
24667         arg_conv.inner = (void*)(arg & (~1));
24668         arg_conv.is_owned = false;
24669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24670         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
24671         return ret_val;
24672 }
24673
24674 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
24675         LDKUpdateFailHTLC orig_conv;
24676         orig_conv.inner = (void*)(orig & (~1));
24677         orig_conv.is_owned = false;
24678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24679         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
24680         uint64_t ret_ref = 0;
24681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24684         ret_ref = (uint64_t)ret_var.inner;
24685         if (ret_var.is_owned) {
24686                 ret_ref |= 1;
24687         }
24688         return ret_ref;
24689 }
24690
24691 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
24692         LDKUpdateFailMalformedHTLC this_obj_conv;
24693         this_obj_conv.inner = (void*)(this_obj & (~1));
24694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24696         UpdateFailMalformedHTLC_free(this_obj_conv);
24697 }
24698
24699 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
24700         LDKUpdateFailMalformedHTLC this_ptr_conv;
24701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24702         this_ptr_conv.is_owned = false;
24703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24704         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24705         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
24706         return ret_arr;
24707 }
24708
24709 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24710         LDKUpdateFailMalformedHTLC this_ptr_conv;
24711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24712         this_ptr_conv.is_owned = false;
24713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24714         LDKThirtyTwoBytes val_ref;
24715         CHECK(*((uint32_t*)val) == 32);
24716         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24717         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
24718 }
24719
24720 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
24721         LDKUpdateFailMalformedHTLC this_ptr_conv;
24722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24723         this_ptr_conv.is_owned = false;
24724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24725         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
24726         return ret_val;
24727 }
24728
24729 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24730         LDKUpdateFailMalformedHTLC this_ptr_conv;
24731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24732         this_ptr_conv.is_owned = false;
24733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24734         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
24735 }
24736
24737 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
24738         LDKUpdateFailMalformedHTLC this_ptr_conv;
24739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24740         this_ptr_conv.is_owned = false;
24741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24742         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
24743         return ret_val;
24744 }
24745
24746 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
24747         LDKUpdateFailMalformedHTLC this_ptr_conv;
24748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24749         this_ptr_conv.is_owned = false;
24750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24751         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
24752 }
24753
24754 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
24755         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
24756 uint64_t ret_ref = 0;
24757 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24758 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24759 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24760 ret_ref = (uint64_t)ret_var.inner;
24761 if (ret_var.is_owned) {
24762         ret_ref |= 1;
24763 }
24764         return ret_ref;
24765 }
24766 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
24767         LDKUpdateFailMalformedHTLC arg_conv;
24768         arg_conv.inner = (void*)(arg & (~1));
24769         arg_conv.is_owned = false;
24770         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24771         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
24772         return ret_val;
24773 }
24774
24775 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
24776         LDKUpdateFailMalformedHTLC orig_conv;
24777         orig_conv.inner = (void*)(orig & (~1));
24778         orig_conv.is_owned = false;
24779         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24780         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
24781         uint64_t ret_ref = 0;
24782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24785         ret_ref = (uint64_t)ret_var.inner;
24786         if (ret_var.is_owned) {
24787                 ret_ref |= 1;
24788         }
24789         return ret_ref;
24790 }
24791
24792 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_obj) {
24793         LDKCommitmentSigned this_obj_conv;
24794         this_obj_conv.inner = (void*)(this_obj & (~1));
24795         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24797         CommitmentSigned_free(this_obj_conv);
24798 }
24799
24800 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
24801         LDKCommitmentSigned this_ptr_conv;
24802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24803         this_ptr_conv.is_owned = false;
24804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24805         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24806         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
24807         return ret_arr;
24808 }
24809
24810 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24811         LDKCommitmentSigned this_ptr_conv;
24812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24813         this_ptr_conv.is_owned = false;
24814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24815         LDKThirtyTwoBytes val_ref;
24816         CHECK(*((uint32_t*)val) == 32);
24817         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24818         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
24819 }
24820
24821 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
24822         LDKCommitmentSigned this_ptr_conv;
24823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24824         this_ptr_conv.is_owned = false;
24825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24826         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
24827         memcpy((uint8_t*)(ret_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
24828         return ret_arr;
24829 }
24830
24831 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24832         LDKCommitmentSigned this_ptr_conv;
24833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24834         this_ptr_conv.is_owned = false;
24835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24836         LDKSignature val_ref;
24837         CHECK(*((uint32_t*)val) == 64);
24838         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
24839         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
24840 }
24841
24842 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
24843         LDKCommitmentSigned this_ptr_conv;
24844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24845         this_ptr_conv.is_owned = false;
24846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24847         LDKCVec_SignatureZ val_constr;
24848         val_constr.datalen = *((uint32_t*)val);
24849         if (val_constr.datalen > 0)
24850                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24851         else
24852                 val_constr.data = NULL;
24853         int8_tArray* val_vals = (int8_tArray*)(val + 4);
24854         for (size_t m = 0; m < val_constr.datalen; m++) {
24855                 int8_tArray val_conv_12 = val_vals[m];
24856                 LDKSignature val_conv_12_ref;
24857                 CHECK(*((uint32_t*)val_conv_12) == 64);
24858                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
24859                 val_constr.data[m] = val_conv_12_ref;
24860         }
24861         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
24862 }
24863
24864 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
24865         LDKThirtyTwoBytes channel_id_arg_ref;
24866         CHECK(*((uint32_t*)channel_id_arg) == 32);
24867         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
24868         LDKSignature signature_arg_ref;
24869         CHECK(*((uint32_t*)signature_arg) == 64);
24870         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
24871         LDKCVec_SignatureZ htlc_signatures_arg_constr;
24872         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
24873         if (htlc_signatures_arg_constr.datalen > 0)
24874                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24875         else
24876                 htlc_signatures_arg_constr.data = NULL;
24877         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
24878         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
24879                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
24880                 LDKSignature htlc_signatures_arg_conv_12_ref;
24881                 CHECK(*((uint32_t*)htlc_signatures_arg_conv_12) == 64);
24882                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, (uint8_t*)(htlc_signatures_arg_conv_12 + 4), 64);
24883                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
24884         }
24885         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
24886         uint64_t ret_ref = 0;
24887         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24888         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24890         ret_ref = (uint64_t)ret_var.inner;
24891         if (ret_var.is_owned) {
24892                 ret_ref |= 1;
24893         }
24894         return ret_ref;
24895 }
24896
24897 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
24898         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
24899 uint64_t ret_ref = 0;
24900 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24901 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24903 ret_ref = (uint64_t)ret_var.inner;
24904 if (ret_var.is_owned) {
24905         ret_ref |= 1;
24906 }
24907         return ret_ref;
24908 }
24909 int64_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
24910         LDKCommitmentSigned arg_conv;
24911         arg_conv.inner = (void*)(arg & (~1));
24912         arg_conv.is_owned = false;
24913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24914         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
24915         return ret_val;
24916 }
24917
24918 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
24919         LDKCommitmentSigned orig_conv;
24920         orig_conv.inner = (void*)(orig & (~1));
24921         orig_conv.is_owned = false;
24922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24923         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
24924         uint64_t ret_ref = 0;
24925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24928         ret_ref = (uint64_t)ret_var.inner;
24929         if (ret_var.is_owned) {
24930                 ret_ref |= 1;
24931         }
24932         return ret_ref;
24933 }
24934
24935 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_obj) {
24936         LDKRevokeAndACK this_obj_conv;
24937         this_obj_conv.inner = (void*)(this_obj & (~1));
24938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24940         RevokeAndACK_free(this_obj_conv);
24941 }
24942
24943 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
24944         LDKRevokeAndACK this_ptr_conv;
24945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24946         this_ptr_conv.is_owned = false;
24947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24948         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24949         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
24950         return ret_arr;
24951 }
24952
24953 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24954         LDKRevokeAndACK this_ptr_conv;
24955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24956         this_ptr_conv.is_owned = false;
24957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24958         LDKThirtyTwoBytes val_ref;
24959         CHECK(*((uint32_t*)val) == 32);
24960         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24961         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
24962 }
24963
24964 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
24965         LDKRevokeAndACK this_ptr_conv;
24966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24967         this_ptr_conv.is_owned = false;
24968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24969         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
24970         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
24971         return ret_arr;
24972 }
24973
24974 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
24975         LDKRevokeAndACK this_ptr_conv;
24976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24977         this_ptr_conv.is_owned = false;
24978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24979         LDKThirtyTwoBytes val_ref;
24980         CHECK(*((uint32_t*)val) == 32);
24981         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
24982         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
24983 }
24984
24985 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
24986         LDKRevokeAndACK this_ptr_conv;
24987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24988         this_ptr_conv.is_owned = false;
24989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24990         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
24991         memcpy((uint8_t*)(ret_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24992         return ret_arr;
24993 }
24994
24995 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
24996         LDKRevokeAndACK this_ptr_conv;
24997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24998         this_ptr_conv.is_owned = false;
24999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25000         LDKPublicKey val_ref;
25001         CHECK(*((uint32_t*)val) == 33);
25002         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25003         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
25004 }
25005
25006 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
25007         LDKThirtyTwoBytes channel_id_arg_ref;
25008         CHECK(*((uint32_t*)channel_id_arg) == 32);
25009         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
25010         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
25011         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
25012         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
25013         LDKPublicKey next_per_commitment_point_arg_ref;
25014         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
25015         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
25016         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
25017         uint64_t ret_ref = 0;
25018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25021         ret_ref = (uint64_t)ret_var.inner;
25022         if (ret_var.is_owned) {
25023                 ret_ref |= 1;
25024         }
25025         return ret_ref;
25026 }
25027
25028 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
25029         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
25030 uint64_t ret_ref = 0;
25031 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25032 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25033 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25034 ret_ref = (uint64_t)ret_var.inner;
25035 if (ret_var.is_owned) {
25036         ret_ref |= 1;
25037 }
25038         return ret_ref;
25039 }
25040 int64_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
25041         LDKRevokeAndACK arg_conv;
25042         arg_conv.inner = (void*)(arg & (~1));
25043         arg_conv.is_owned = false;
25044         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25045         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
25046         return ret_val;
25047 }
25048
25049 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
25050         LDKRevokeAndACK orig_conv;
25051         orig_conv.inner = (void*)(orig & (~1));
25052         orig_conv.is_owned = false;
25053         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25054         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
25055         uint64_t ret_ref = 0;
25056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25059         ret_ref = (uint64_t)ret_var.inner;
25060         if (ret_var.is_owned) {
25061                 ret_ref |= 1;
25062         }
25063         return ret_ref;
25064 }
25065
25066 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_obj) {
25067         LDKUpdateFee this_obj_conv;
25068         this_obj_conv.inner = (void*)(this_obj & (~1));
25069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25071         UpdateFee_free(this_obj_conv);
25072 }
25073
25074 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
25075         LDKUpdateFee this_ptr_conv;
25076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25077         this_ptr_conv.is_owned = false;
25078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25079         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25080         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
25081         return ret_arr;
25082 }
25083
25084 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25085         LDKUpdateFee this_ptr_conv;
25086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25087         this_ptr_conv.is_owned = false;
25088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25089         LDKThirtyTwoBytes val_ref;
25090         CHECK(*((uint32_t*)val) == 32);
25091         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25092         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
25093 }
25094
25095 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
25096         LDKUpdateFee this_ptr_conv;
25097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25098         this_ptr_conv.is_owned = false;
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25100         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
25101         return ret_val;
25102 }
25103
25104 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
25105         LDKUpdateFee this_ptr_conv;
25106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25107         this_ptr_conv.is_owned = false;
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25109         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
25110 }
25111
25112 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
25113         LDKThirtyTwoBytes channel_id_arg_ref;
25114         CHECK(*((uint32_t*)channel_id_arg) == 32);
25115         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
25116         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
25117         uint64_t ret_ref = 0;
25118         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25119         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25121         ret_ref = (uint64_t)ret_var.inner;
25122         if (ret_var.is_owned) {
25123                 ret_ref |= 1;
25124         }
25125         return ret_ref;
25126 }
25127
25128 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
25129         LDKUpdateFee ret_var = UpdateFee_clone(arg);
25130 uint64_t ret_ref = 0;
25131 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25132 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25133 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25134 ret_ref = (uint64_t)ret_var.inner;
25135 if (ret_var.is_owned) {
25136         ret_ref |= 1;
25137 }
25138         return ret_ref;
25139 }
25140 int64_t  __attribute__((visibility("default"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
25141         LDKUpdateFee arg_conv;
25142         arg_conv.inner = (void*)(arg & (~1));
25143         arg_conv.is_owned = false;
25144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25145         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
25146         return ret_val;
25147 }
25148
25149 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
25150         LDKUpdateFee orig_conv;
25151         orig_conv.inner = (void*)(orig & (~1));
25152         orig_conv.is_owned = false;
25153         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25154         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
25155         uint64_t ret_ref = 0;
25156         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25157         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25159         ret_ref = (uint64_t)ret_var.inner;
25160         if (ret_var.is_owned) {
25161                 ret_ref |= 1;
25162         }
25163         return ret_ref;
25164 }
25165
25166 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_obj) {
25167         LDKDataLossProtect this_obj_conv;
25168         this_obj_conv.inner = (void*)(this_obj & (~1));
25169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25171         DataLossProtect_free(this_obj_conv);
25172 }
25173
25174 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
25175         LDKDataLossProtect this_ptr_conv;
25176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25177         this_ptr_conv.is_owned = false;
25178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25179         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25180         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
25181         return ret_arr;
25182 }
25183
25184 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
25185         LDKDataLossProtect this_ptr_conv;
25186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25187         this_ptr_conv.is_owned = false;
25188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25189         LDKThirtyTwoBytes val_ref;
25190         CHECK(*((uint32_t*)val) == 32);
25191         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25192         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
25193 }
25194
25195 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
25196         LDKDataLossProtect this_ptr_conv;
25197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25198         this_ptr_conv.is_owned = false;
25199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25200         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25201         memcpy((uint8_t*)(ret_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
25202         return ret_arr;
25203 }
25204
25205 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
25206         LDKDataLossProtect this_ptr_conv;
25207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25208         this_ptr_conv.is_owned = false;
25209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25210         LDKPublicKey val_ref;
25211         CHECK(*((uint32_t*)val) == 33);
25212         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25213         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
25214 }
25215
25216 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
25217         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
25218         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
25219         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
25220         LDKPublicKey my_current_per_commitment_point_arg_ref;
25221         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
25222         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
25223         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
25224         uint64_t ret_ref = 0;
25225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25228         ret_ref = (uint64_t)ret_var.inner;
25229         if (ret_var.is_owned) {
25230                 ret_ref |= 1;
25231         }
25232         return ret_ref;
25233 }
25234
25235 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
25236         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
25237 uint64_t ret_ref = 0;
25238 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25239 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25240 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25241 ret_ref = (uint64_t)ret_var.inner;
25242 if (ret_var.is_owned) {
25243         ret_ref |= 1;
25244 }
25245         return ret_ref;
25246 }
25247 int64_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
25248         LDKDataLossProtect arg_conv;
25249         arg_conv.inner = (void*)(arg & (~1));
25250         arg_conv.is_owned = false;
25251         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25252         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
25253         return ret_val;
25254 }
25255
25256 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
25257         LDKDataLossProtect orig_conv;
25258         orig_conv.inner = (void*)(orig & (~1));
25259         orig_conv.is_owned = false;
25260         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25261         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
25262         uint64_t ret_ref = 0;
25263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25266         ret_ref = (uint64_t)ret_var.inner;
25267         if (ret_var.is_owned) {
25268                 ret_ref |= 1;
25269         }
25270         return ret_ref;
25271 }
25272
25273 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_obj) {
25274         LDKChannelReestablish this_obj_conv;
25275         this_obj_conv.inner = (void*)(this_obj & (~1));
25276         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25278         ChannelReestablish_free(this_obj_conv);
25279 }
25280
25281 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
25282         LDKChannelReestablish this_ptr_conv;
25283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25284         this_ptr_conv.is_owned = false;
25285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25286         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25287         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
25288         return ret_arr;
25289 }
25290
25291 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25292         LDKChannelReestablish this_ptr_conv;
25293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25294         this_ptr_conv.is_owned = false;
25295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25296         LDKThirtyTwoBytes val_ref;
25297         CHECK(*((uint32_t*)val) == 32);
25298         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25299         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
25300 }
25301
25302 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
25303         LDKChannelReestablish this_ptr_conv;
25304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25305         this_ptr_conv.is_owned = false;
25306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25307         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
25308         return ret_val;
25309 }
25310
25311 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
25312         LDKChannelReestablish this_ptr_conv;
25313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25314         this_ptr_conv.is_owned = false;
25315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25316         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
25317 }
25318
25319 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
25320         LDKChannelReestablish this_ptr_conv;
25321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25322         this_ptr_conv.is_owned = false;
25323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25324         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
25325         return ret_val;
25326 }
25327
25328 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
25329         LDKChannelReestablish this_ptr_conv;
25330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25331         this_ptr_conv.is_owned = false;
25332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25333         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
25334 }
25335
25336 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
25337         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
25338 uint64_t ret_ref = 0;
25339 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25340 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25341 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25342 ret_ref = (uint64_t)ret_var.inner;
25343 if (ret_var.is_owned) {
25344         ret_ref |= 1;
25345 }
25346         return ret_ref;
25347 }
25348 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
25349         LDKChannelReestablish arg_conv;
25350         arg_conv.inner = (void*)(arg & (~1));
25351         arg_conv.is_owned = false;
25352         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25353         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
25354         return ret_val;
25355 }
25356
25357 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
25358         LDKChannelReestablish orig_conv;
25359         orig_conv.inner = (void*)(orig & (~1));
25360         orig_conv.is_owned = false;
25361         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25362         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
25363         uint64_t ret_ref = 0;
25364         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25365         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25367         ret_ref = (uint64_t)ret_var.inner;
25368         if (ret_var.is_owned) {
25369                 ret_ref |= 1;
25370         }
25371         return ret_ref;
25372 }
25373
25374 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
25375         LDKAnnouncementSignatures this_obj_conv;
25376         this_obj_conv.inner = (void*)(this_obj & (~1));
25377         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25379         AnnouncementSignatures_free(this_obj_conv);
25380 }
25381
25382 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
25383         LDKAnnouncementSignatures this_ptr_conv;
25384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25385         this_ptr_conv.is_owned = false;
25386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25387         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25388         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
25389         return ret_arr;
25390 }
25391
25392 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25393         LDKAnnouncementSignatures this_ptr_conv;
25394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25395         this_ptr_conv.is_owned = false;
25396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25397         LDKThirtyTwoBytes val_ref;
25398         CHECK(*((uint32_t*)val) == 32);
25399         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25400         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
25401 }
25402
25403 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
25404         LDKAnnouncementSignatures this_ptr_conv;
25405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25406         this_ptr_conv.is_owned = false;
25407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25408         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
25409         return ret_val;
25410 }
25411
25412 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25413         LDKAnnouncementSignatures this_ptr_conv;
25414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25415         this_ptr_conv.is_owned = false;
25416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25417         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
25418 }
25419
25420 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
25421         LDKAnnouncementSignatures this_ptr_conv;
25422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25423         this_ptr_conv.is_owned = false;
25424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25425         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25426         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
25427         return ret_arr;
25428 }
25429
25430 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
25431         LDKAnnouncementSignatures this_ptr_conv;
25432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25433         this_ptr_conv.is_owned = false;
25434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25435         LDKSignature val_ref;
25436         CHECK(*((uint32_t*)val) == 64);
25437         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25438         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
25439 }
25440
25441 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
25442         LDKAnnouncementSignatures this_ptr_conv;
25443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25444         this_ptr_conv.is_owned = false;
25445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25446         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25447         memcpy((uint8_t*)(ret_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
25448         return ret_arr;
25449 }
25450
25451 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
25452         LDKAnnouncementSignatures this_ptr_conv;
25453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25454         this_ptr_conv.is_owned = false;
25455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25456         LDKSignature val_ref;
25457         CHECK(*((uint32_t*)val) == 64);
25458         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25459         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
25460 }
25461
25462 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_new(int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
25463         LDKThirtyTwoBytes channel_id_arg_ref;
25464         CHECK(*((uint32_t*)channel_id_arg) == 32);
25465         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
25466         LDKSignature node_signature_arg_ref;
25467         CHECK(*((uint32_t*)node_signature_arg) == 64);
25468         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
25469         LDKSignature bitcoin_signature_arg_ref;
25470         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
25471         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
25472         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
25473         uint64_t ret_ref = 0;
25474         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25475         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25477         ret_ref = (uint64_t)ret_var.inner;
25478         if (ret_var.is_owned) {
25479                 ret_ref |= 1;
25480         }
25481         return ret_ref;
25482 }
25483
25484 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
25485         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
25486 uint64_t ret_ref = 0;
25487 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25488 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25490 ret_ref = (uint64_t)ret_var.inner;
25491 if (ret_var.is_owned) {
25492         ret_ref |= 1;
25493 }
25494         return ret_ref;
25495 }
25496 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
25497         LDKAnnouncementSignatures arg_conv;
25498         arg_conv.inner = (void*)(arg & (~1));
25499         arg_conv.is_owned = false;
25500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25501         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
25502         return ret_val;
25503 }
25504
25505 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
25506         LDKAnnouncementSignatures orig_conv;
25507         orig_conv.inner = (void*)(orig & (~1));
25508         orig_conv.is_owned = false;
25509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25510         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
25511         uint64_t ret_ref = 0;
25512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25513         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25515         ret_ref = (uint64_t)ret_var.inner;
25516         if (ret_var.is_owned) {
25517                 ret_ref |= 1;
25518         }
25519         return ret_ref;
25520 }
25521
25522 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
25523         if ((this_ptr & 1) != 0) return;
25524         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
25525         CHECK_ACCESS(this_ptr_ptr);
25526         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
25527         FREE((void*)this_ptr);
25528         NetAddress_free(this_ptr_conv);
25529 }
25530
25531 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
25532         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25533         *ret_copy = NetAddress_clone(arg);
25534 uint64_t ret_ref = (uint64_t)ret_copy;
25535         return ret_ref;
25536 }
25537 int64_t  __attribute__((visibility("default"))) TS_NetAddress_clone_ptr(uint32_t arg) {
25538         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
25539         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
25540         return ret_val;
25541 }
25542
25543 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
25544         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
25545         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25546         *ret_copy = NetAddress_clone(orig_conv);
25547         uint64_t ret_ref = (uint64_t)ret_copy;
25548         return ret_ref;
25549 }
25550
25551 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
25552         LDKFourBytes addr_ref;
25553         CHECK(*((uint32_t*)addr) == 4);
25554         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 4);
25555         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25556         *ret_copy = NetAddress_ipv4(addr_ref, port);
25557         uint64_t ret_ref = (uint64_t)ret_copy;
25558         return ret_ref;
25559 }
25560
25561 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
25562         LDKSixteenBytes addr_ref;
25563         CHECK(*((uint32_t*)addr) == 16);
25564         memcpy(addr_ref.data, (uint8_t*)(addr + 4), 16);
25565         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25566         *ret_copy = NetAddress_ipv6(addr_ref, port);
25567         uint64_t ret_ref = (uint64_t)ret_copy;
25568         return ret_ref;
25569 }
25570
25571 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v2(int8_tArray a) {
25572         LDKTwelveBytes a_ref;
25573         CHECK(*((uint32_t*)a) == 12);
25574         memcpy(a_ref.data, (uint8_t*)(a + 4), 12);
25575         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25576         *ret_copy = NetAddress_onion_v2(a_ref);
25577         uint64_t ret_ref = (uint64_t)ret_copy;
25578         return ret_ref;
25579 }
25580
25581 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_onion_v3(int8_tArray ed25519_pubkey, int16_t checksum, int8_t version, int16_t port) {
25582         LDKThirtyTwoBytes ed25519_pubkey_ref;
25583         CHECK(*((uint32_t*)ed25519_pubkey) == 32);
25584         memcpy(ed25519_pubkey_ref.data, (uint8_t*)(ed25519_pubkey + 4), 32);
25585         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25586         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
25587         uint64_t ret_ref = (uint64_t)ret_copy;
25588         return ret_ref;
25589 }
25590
25591 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
25592         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
25593         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
25594         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
25595         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
25596         CVec_u8Z_free(ret_var);
25597         return ret_arr;
25598 }
25599
25600 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_read(int8_tArray ser) {
25601         LDKu8slice ser_ref;
25602         ser_ref.datalen = *((uint32_t*)ser);
25603         ser_ref.data = (int8_t*)(ser + 4);
25604         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
25605         *ret_conv = NetAddress_read(ser_ref);
25606         return (uint64_t)ret_conv;
25607 }
25608
25609 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
25610         LDKUnsignedNodeAnnouncement this_obj_conv;
25611         this_obj_conv.inner = (void*)(this_obj & (~1));
25612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25614         UnsignedNodeAnnouncement_free(this_obj_conv);
25615 }
25616
25617 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
25618         LDKUnsignedNodeAnnouncement this_ptr_conv;
25619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25620         this_ptr_conv.is_owned = false;
25621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25622         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
25623         uint64_t ret_ref = 0;
25624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25627         ret_ref = (uint64_t)ret_var.inner;
25628         if (ret_var.is_owned) {
25629                 ret_ref |= 1;
25630         }
25631         return ret_ref;
25632 }
25633
25634 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25635         LDKUnsignedNodeAnnouncement this_ptr_conv;
25636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25637         this_ptr_conv.is_owned = false;
25638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25639         LDKNodeFeatures val_conv;
25640         val_conv.inner = (void*)(val & (~1));
25641         val_conv.is_owned = (val & 1) || (val == 0);
25642         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25643         val_conv = NodeFeatures_clone(&val_conv);
25644         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
25645 }
25646
25647 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
25648         LDKUnsignedNodeAnnouncement this_ptr_conv;
25649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25650         this_ptr_conv.is_owned = false;
25651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25652         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
25653         return ret_val;
25654 }
25655
25656 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
25657         LDKUnsignedNodeAnnouncement this_ptr_conv;
25658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25659         this_ptr_conv.is_owned = false;
25660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25661         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
25662 }
25663
25664 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
25665         LDKUnsignedNodeAnnouncement this_ptr_conv;
25666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25667         this_ptr_conv.is_owned = false;
25668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25669         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25670         memcpy((uint8_t*)(ret_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
25671         return ret_arr;
25672 }
25673
25674 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
25675         LDKUnsignedNodeAnnouncement this_ptr_conv;
25676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25677         this_ptr_conv.is_owned = false;
25678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25679         LDKPublicKey val_ref;
25680         CHECK(*((uint32_t*)val) == 33);
25681         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
25682         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
25683 }
25684
25685 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
25686         LDKUnsignedNodeAnnouncement this_ptr_conv;
25687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25688         this_ptr_conv.is_owned = false;
25689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25690         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
25691         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
25692         return ret_arr;
25693 }
25694
25695 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
25696         LDKUnsignedNodeAnnouncement this_ptr_conv;
25697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25698         this_ptr_conv.is_owned = false;
25699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25700         LDKThreeBytes val_ref;
25701         CHECK(*((uint32_t*)val) == 3);
25702         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
25703         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
25704 }
25705
25706 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
25707         LDKUnsignedNodeAnnouncement this_ptr_conv;
25708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25709         this_ptr_conv.is_owned = false;
25710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25711         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25712         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
25713         return ret_arr;
25714 }
25715
25716 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
25717         LDKUnsignedNodeAnnouncement this_ptr_conv;
25718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25719         this_ptr_conv.is_owned = false;
25720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25721         LDKThirtyTwoBytes val_ref;
25722         CHECK(*((uint32_t*)val) == 32);
25723         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25724         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
25725 }
25726
25727 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
25728         LDKUnsignedNodeAnnouncement this_ptr_conv;
25729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25730         this_ptr_conv.is_owned = false;
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25732         LDKCVec_NetAddressZ val_constr;
25733         val_constr.datalen = *((uint32_t*)val);
25734         if (val_constr.datalen > 0)
25735                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25736         else
25737                 val_constr.data = NULL;
25738         uint32_t* val_vals = (uint32_t*)(val + 4);
25739         for (size_t m = 0; m < val_constr.datalen; m++) {
25740                 uint32_t val_conv_12 = val_vals[m];
25741                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
25742                 CHECK_ACCESS(val_conv_12_ptr);
25743                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
25744                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
25745                 val_constr.data[m] = val_conv_12_conv;
25746         }
25747         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
25748 }
25749
25750 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
25751         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
25752 uint64_t ret_ref = 0;
25753 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25754 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25755 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25756 ret_ref = (uint64_t)ret_var.inner;
25757 if (ret_var.is_owned) {
25758         ret_ref |= 1;
25759 }
25760         return ret_ref;
25761 }
25762 int64_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
25763         LDKUnsignedNodeAnnouncement arg_conv;
25764         arg_conv.inner = (void*)(arg & (~1));
25765         arg_conv.is_owned = false;
25766         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25767         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
25768         return ret_val;
25769 }
25770
25771 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
25772         LDKUnsignedNodeAnnouncement orig_conv;
25773         orig_conv.inner = (void*)(orig & (~1));
25774         orig_conv.is_owned = false;
25775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25776         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
25777         uint64_t ret_ref = 0;
25778         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25779         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25781         ret_ref = (uint64_t)ret_var.inner;
25782         if (ret_var.is_owned) {
25783                 ret_ref |= 1;
25784         }
25785         return ret_ref;
25786 }
25787
25788 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
25789         LDKNodeAnnouncement this_obj_conv;
25790         this_obj_conv.inner = (void*)(this_obj & (~1));
25791         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25793         NodeAnnouncement_free(this_obj_conv);
25794 }
25795
25796 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
25797         LDKNodeAnnouncement this_ptr_conv;
25798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25799         this_ptr_conv.is_owned = false;
25800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25801         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
25802         memcpy((uint8_t*)(ret_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
25803         return ret_arr;
25804 }
25805
25806 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
25807         LDKNodeAnnouncement this_ptr_conv;
25808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25809         this_ptr_conv.is_owned = false;
25810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25811         LDKSignature val_ref;
25812         CHECK(*((uint32_t*)val) == 64);
25813         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
25814         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
25815 }
25816
25817 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
25818         LDKNodeAnnouncement this_ptr_conv;
25819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25820         this_ptr_conv.is_owned = false;
25821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25822         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
25823         uint64_t ret_ref = 0;
25824         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25825         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25827         ret_ref = (uint64_t)ret_var.inner;
25828         if (ret_var.is_owned) {
25829                 ret_ref |= 1;
25830         }
25831         return ret_ref;
25832 }
25833
25834 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
25835         LDKNodeAnnouncement this_ptr_conv;
25836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25837         this_ptr_conv.is_owned = false;
25838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25839         LDKUnsignedNodeAnnouncement val_conv;
25840         val_conv.inner = (void*)(val & (~1));
25841         val_conv.is_owned = (val & 1) || (val == 0);
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25843         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
25844         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
25845 }
25846
25847 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
25848         LDKSignature signature_arg_ref;
25849         CHECK(*((uint32_t*)signature_arg) == 64);
25850         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
25851         LDKUnsignedNodeAnnouncement contents_arg_conv;
25852         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25853         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25854         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25855         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
25856         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
25857         uint64_t ret_ref = 0;
25858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25861         ret_ref = (uint64_t)ret_var.inner;
25862         if (ret_var.is_owned) {
25863                 ret_ref |= 1;
25864         }
25865         return ret_ref;
25866 }
25867
25868 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
25869         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
25870 uint64_t ret_ref = 0;
25871 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25872 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25873 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25874 ret_ref = (uint64_t)ret_var.inner;
25875 if (ret_var.is_owned) {
25876         ret_ref |= 1;
25877 }
25878         return ret_ref;
25879 }
25880 int64_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
25881         LDKNodeAnnouncement arg_conv;
25882         arg_conv.inner = (void*)(arg & (~1));
25883         arg_conv.is_owned = false;
25884         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25885         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
25886         return ret_val;
25887 }
25888
25889 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
25890         LDKNodeAnnouncement orig_conv;
25891         orig_conv.inner = (void*)(orig & (~1));
25892         orig_conv.is_owned = false;
25893         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25894         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
25895         uint64_t ret_ref = 0;
25896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25899         ret_ref = (uint64_t)ret_var.inner;
25900         if (ret_var.is_owned) {
25901                 ret_ref |= 1;
25902         }
25903         return ret_ref;
25904 }
25905
25906 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
25907         LDKUnsignedChannelAnnouncement this_obj_conv;
25908         this_obj_conv.inner = (void*)(this_obj & (~1));
25909         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25911         UnsignedChannelAnnouncement_free(this_obj_conv);
25912 }
25913
25914 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
25915         LDKUnsignedChannelAnnouncement this_ptr_conv;
25916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25917         this_ptr_conv.is_owned = false;
25918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25919         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
25920         uint64_t ret_ref = 0;
25921         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25922         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25924         ret_ref = (uint64_t)ret_var.inner;
25925         if (ret_var.is_owned) {
25926                 ret_ref |= 1;
25927         }
25928         return ret_ref;
25929 }
25930
25931 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25932         LDKUnsignedChannelAnnouncement this_ptr_conv;
25933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25934         this_ptr_conv.is_owned = false;
25935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25936         LDKChannelFeatures val_conv;
25937         val_conv.inner = (void*)(val & (~1));
25938         val_conv.is_owned = (val & 1) || (val == 0);
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25940         val_conv = ChannelFeatures_clone(&val_conv);
25941         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
25942 }
25943
25944 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
25945         LDKUnsignedChannelAnnouncement this_ptr_conv;
25946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25947         this_ptr_conv.is_owned = false;
25948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25949         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
25950         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
25951         return ret_arr;
25952 }
25953
25954 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
25955         LDKUnsignedChannelAnnouncement this_ptr_conv;
25956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25957         this_ptr_conv.is_owned = false;
25958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25959         LDKThirtyTwoBytes val_ref;
25960         CHECK(*((uint32_t*)val) == 32);
25961         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
25962         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
25963 }
25964
25965 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
25966         LDKUnsignedChannelAnnouncement this_ptr_conv;
25967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25968         this_ptr_conv.is_owned = false;
25969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25970         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
25971         return ret_val;
25972 }
25973
25974 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25975         LDKUnsignedChannelAnnouncement this_ptr_conv;
25976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25977         this_ptr_conv.is_owned = false;
25978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25979         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
25980 }
25981
25982 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
25983         LDKUnsignedChannelAnnouncement this_ptr_conv;
25984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25985         this_ptr_conv.is_owned = false;
25986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25987         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
25988         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
25989         return ret_arr;
25990 }
25991
25992 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
25993         LDKUnsignedChannelAnnouncement this_ptr_conv;
25994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25995         this_ptr_conv.is_owned = false;
25996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25997         LDKPublicKey val_ref;
25998         CHECK(*((uint32_t*)val) == 33);
25999         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
26000         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
26001 }
26002
26003 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
26004         LDKUnsignedChannelAnnouncement this_ptr_conv;
26005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26006         this_ptr_conv.is_owned = false;
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26008         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26009         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
26010         return ret_arr;
26011 }
26012
26013 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
26014         LDKUnsignedChannelAnnouncement this_ptr_conv;
26015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26016         this_ptr_conv.is_owned = false;
26017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26018         LDKPublicKey val_ref;
26019         CHECK(*((uint32_t*)val) == 33);
26020         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
26021         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
26022 }
26023
26024 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
26025         LDKUnsignedChannelAnnouncement this_ptr_conv;
26026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26027         this_ptr_conv.is_owned = false;
26028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26029         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26030         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
26031         return ret_arr;
26032 }
26033
26034 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
26035         LDKUnsignedChannelAnnouncement this_ptr_conv;
26036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26037         this_ptr_conv.is_owned = false;
26038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26039         LDKPublicKey val_ref;
26040         CHECK(*((uint32_t*)val) == 33);
26041         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
26042         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
26043 }
26044
26045 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
26046         LDKUnsignedChannelAnnouncement this_ptr_conv;
26047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26048         this_ptr_conv.is_owned = false;
26049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26050         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
26051         memcpy((uint8_t*)(ret_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
26052         return ret_arr;
26053 }
26054
26055 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
26056         LDKUnsignedChannelAnnouncement this_ptr_conv;
26057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26058         this_ptr_conv.is_owned = false;
26059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26060         LDKPublicKey val_ref;
26061         CHECK(*((uint32_t*)val) == 33);
26062         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
26063         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
26064 }
26065
26066 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
26067         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
26068 uint64_t ret_ref = 0;
26069 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26070 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26071 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26072 ret_ref = (uint64_t)ret_var.inner;
26073 if (ret_var.is_owned) {
26074         ret_ref |= 1;
26075 }
26076         return ret_ref;
26077 }
26078 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
26079         LDKUnsignedChannelAnnouncement arg_conv;
26080         arg_conv.inner = (void*)(arg & (~1));
26081         arg_conv.is_owned = false;
26082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26083         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
26084         return ret_val;
26085 }
26086
26087 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
26088         LDKUnsignedChannelAnnouncement orig_conv;
26089         orig_conv.inner = (void*)(orig & (~1));
26090         orig_conv.is_owned = false;
26091         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26092         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
26093         uint64_t ret_ref = 0;
26094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26097         ret_ref = (uint64_t)ret_var.inner;
26098         if (ret_var.is_owned) {
26099                 ret_ref |= 1;
26100         }
26101         return ret_ref;
26102 }
26103
26104 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
26105         LDKChannelAnnouncement this_obj_conv;
26106         this_obj_conv.inner = (void*)(this_obj & (~1));
26107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26109         ChannelAnnouncement_free(this_obj_conv);
26110 }
26111
26112 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
26113         LDKChannelAnnouncement this_ptr_conv;
26114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26115         this_ptr_conv.is_owned = false;
26116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26117         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
26118         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
26119         return ret_arr;
26120 }
26121
26122 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
26123         LDKChannelAnnouncement this_ptr_conv;
26124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26125         this_ptr_conv.is_owned = false;
26126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26127         LDKSignature val_ref;
26128         CHECK(*((uint32_t*)val) == 64);
26129         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
26130         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
26131 }
26132
26133 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
26134         LDKChannelAnnouncement this_ptr_conv;
26135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26136         this_ptr_conv.is_owned = false;
26137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26138         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
26139         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
26140         return ret_arr;
26141 }
26142
26143 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
26144         LDKChannelAnnouncement this_ptr_conv;
26145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26146         this_ptr_conv.is_owned = false;
26147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26148         LDKSignature val_ref;
26149         CHECK(*((uint32_t*)val) == 64);
26150         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
26151         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
26152 }
26153
26154 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
26155         LDKChannelAnnouncement this_ptr_conv;
26156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26157         this_ptr_conv.is_owned = false;
26158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26159         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
26160         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
26161         return ret_arr;
26162 }
26163
26164 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
26165         LDKChannelAnnouncement this_ptr_conv;
26166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26167         this_ptr_conv.is_owned = false;
26168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26169         LDKSignature val_ref;
26170         CHECK(*((uint32_t*)val) == 64);
26171         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
26172         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
26173 }
26174
26175 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
26176         LDKChannelAnnouncement this_ptr_conv;
26177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26178         this_ptr_conv.is_owned = false;
26179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26180         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
26181         memcpy((uint8_t*)(ret_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
26182         return ret_arr;
26183 }
26184
26185 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
26186         LDKChannelAnnouncement this_ptr_conv;
26187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26188         this_ptr_conv.is_owned = false;
26189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26190         LDKSignature val_ref;
26191         CHECK(*((uint32_t*)val) == 64);
26192         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
26193         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
26194 }
26195
26196 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
26197         LDKChannelAnnouncement this_ptr_conv;
26198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26199         this_ptr_conv.is_owned = false;
26200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26201         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
26202         uint64_t ret_ref = 0;
26203         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26204         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26206         ret_ref = (uint64_t)ret_var.inner;
26207         if (ret_var.is_owned) {
26208                 ret_ref |= 1;
26209         }
26210         return ret_ref;
26211 }
26212
26213 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
26214         LDKChannelAnnouncement this_ptr_conv;
26215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26216         this_ptr_conv.is_owned = false;
26217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26218         LDKUnsignedChannelAnnouncement val_conv;
26219         val_conv.inner = (void*)(val & (~1));
26220         val_conv.is_owned = (val & 1) || (val == 0);
26221         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26222         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
26223         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
26224 }
26225
26226 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_new(int8_tArray node_signature_1_arg, int8_tArray node_signature_2_arg, int8_tArray bitcoin_signature_1_arg, int8_tArray bitcoin_signature_2_arg, uint32_t contents_arg) {
26227         LDKSignature node_signature_1_arg_ref;
26228         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
26229         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
26230         LDKSignature node_signature_2_arg_ref;
26231         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
26232         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
26233         LDKSignature bitcoin_signature_1_arg_ref;
26234         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
26235         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
26236         LDKSignature bitcoin_signature_2_arg_ref;
26237         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
26238         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
26239         LDKUnsignedChannelAnnouncement contents_arg_conv;
26240         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26241         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26242         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26243         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
26244         LDKChannelAnnouncement ret_var = ChannelAnnouncement_new(node_signature_1_arg_ref, node_signature_2_arg_ref, bitcoin_signature_1_arg_ref, bitcoin_signature_2_arg_ref, contents_arg_conv);
26245         uint64_t ret_ref = 0;
26246         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26247         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26249         ret_ref = (uint64_t)ret_var.inner;
26250         if (ret_var.is_owned) {
26251                 ret_ref |= 1;
26252         }
26253         return ret_ref;
26254 }
26255
26256 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
26257         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
26258 uint64_t ret_ref = 0;
26259 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26260 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26261 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26262 ret_ref = (uint64_t)ret_var.inner;
26263 if (ret_var.is_owned) {
26264         ret_ref |= 1;
26265 }
26266         return ret_ref;
26267 }
26268 int64_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
26269         LDKChannelAnnouncement arg_conv;
26270         arg_conv.inner = (void*)(arg & (~1));
26271         arg_conv.is_owned = false;
26272         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26273         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
26274         return ret_val;
26275 }
26276
26277 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
26278         LDKChannelAnnouncement orig_conv;
26279         orig_conv.inner = (void*)(orig & (~1));
26280         orig_conv.is_owned = false;
26281         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26282         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
26283         uint64_t ret_ref = 0;
26284         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26285         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26287         ret_ref = (uint64_t)ret_var.inner;
26288         if (ret_var.is_owned) {
26289                 ret_ref |= 1;
26290         }
26291         return ret_ref;
26292 }
26293
26294 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
26295         LDKUnsignedChannelUpdate this_obj_conv;
26296         this_obj_conv.inner = (void*)(this_obj & (~1));
26297         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26299         UnsignedChannelUpdate_free(this_obj_conv);
26300 }
26301
26302 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
26303         LDKUnsignedChannelUpdate this_ptr_conv;
26304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26305         this_ptr_conv.is_owned = false;
26306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26307         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26308         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
26309         return ret_arr;
26310 }
26311
26312 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26313         LDKUnsignedChannelUpdate this_ptr_conv;
26314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26315         this_ptr_conv.is_owned = false;
26316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26317         LDKThirtyTwoBytes val_ref;
26318         CHECK(*((uint32_t*)val) == 32);
26319         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26320         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
26321 }
26322
26323 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
26324         LDKUnsignedChannelUpdate this_ptr_conv;
26325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26326         this_ptr_conv.is_owned = false;
26327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26328         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
26329         return ret_val;
26330 }
26331
26332 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
26333         LDKUnsignedChannelUpdate this_ptr_conv;
26334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26335         this_ptr_conv.is_owned = false;
26336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26337         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
26338 }
26339
26340 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
26341         LDKUnsignedChannelUpdate this_ptr_conv;
26342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26343         this_ptr_conv.is_owned = false;
26344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26345         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
26346         return ret_val;
26347 }
26348
26349 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
26350         LDKUnsignedChannelUpdate this_ptr_conv;
26351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26352         this_ptr_conv.is_owned = false;
26353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26354         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
26355 }
26356
26357 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
26358         LDKUnsignedChannelUpdate this_ptr_conv;
26359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26360         this_ptr_conv.is_owned = false;
26361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26362         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
26363         return ret_val;
26364 }
26365
26366 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
26367         LDKUnsignedChannelUpdate this_ptr_conv;
26368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26369         this_ptr_conv.is_owned = false;
26370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26371         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
26372 }
26373
26374 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
26375         LDKUnsignedChannelUpdate this_ptr_conv;
26376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26377         this_ptr_conv.is_owned = false;
26378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26379         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
26380         return ret_val;
26381 }
26382
26383 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
26384         LDKUnsignedChannelUpdate this_ptr_conv;
26385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26386         this_ptr_conv.is_owned = false;
26387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26388         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
26389 }
26390
26391 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
26392         LDKUnsignedChannelUpdate this_ptr_conv;
26393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26394         this_ptr_conv.is_owned = false;
26395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26396         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
26397         return ret_val;
26398 }
26399
26400 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26401         LDKUnsignedChannelUpdate this_ptr_conv;
26402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26403         this_ptr_conv.is_owned = false;
26404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26405         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
26406 }
26407
26408 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
26409         LDKUnsignedChannelUpdate this_ptr_conv;
26410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26411         this_ptr_conv.is_owned = false;
26412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26413         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
26414         return ret_val;
26415 }
26416
26417 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
26418         LDKUnsignedChannelUpdate this_ptr_conv;
26419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26420         this_ptr_conv.is_owned = false;
26421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26422         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
26423 }
26424
26425 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
26426         LDKUnsignedChannelUpdate this_ptr_conv;
26427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26428         this_ptr_conv.is_owned = false;
26429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26430         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
26431         return ret_val;
26432 }
26433
26434 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
26435         LDKUnsignedChannelUpdate this_ptr_conv;
26436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26437         this_ptr_conv.is_owned = false;
26438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26439         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
26440 }
26441
26442 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
26443         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
26444 uint64_t ret_ref = 0;
26445 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26446 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26448 ret_ref = (uint64_t)ret_var.inner;
26449 if (ret_var.is_owned) {
26450         ret_ref |= 1;
26451 }
26452         return ret_ref;
26453 }
26454 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
26455         LDKUnsignedChannelUpdate arg_conv;
26456         arg_conv.inner = (void*)(arg & (~1));
26457         arg_conv.is_owned = false;
26458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26459         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
26460         return ret_val;
26461 }
26462
26463 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
26464         LDKUnsignedChannelUpdate orig_conv;
26465         orig_conv.inner = (void*)(orig & (~1));
26466         orig_conv.is_owned = false;
26467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26468         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
26469         uint64_t ret_ref = 0;
26470         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26471         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26473         ret_ref = (uint64_t)ret_var.inner;
26474         if (ret_var.is_owned) {
26475                 ret_ref |= 1;
26476         }
26477         return ret_ref;
26478 }
26479
26480 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_obj) {
26481         LDKChannelUpdate this_obj_conv;
26482         this_obj_conv.inner = (void*)(this_obj & (~1));
26483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26485         ChannelUpdate_free(this_obj_conv);
26486 }
26487
26488 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
26489         LDKChannelUpdate this_ptr_conv;
26490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26491         this_ptr_conv.is_owned = false;
26492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26493         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
26494         memcpy((uint8_t*)(ret_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
26495         return ret_arr;
26496 }
26497
26498 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
26499         LDKChannelUpdate this_ptr_conv;
26500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26501         this_ptr_conv.is_owned = false;
26502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26503         LDKSignature val_ref;
26504         CHECK(*((uint32_t*)val) == 64);
26505         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
26506         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
26507 }
26508
26509 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
26510         LDKChannelUpdate this_ptr_conv;
26511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26512         this_ptr_conv.is_owned = false;
26513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26514         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
26515         uint64_t ret_ref = 0;
26516         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26517         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26519         ret_ref = (uint64_t)ret_var.inner;
26520         if (ret_var.is_owned) {
26521                 ret_ref |= 1;
26522         }
26523         return ret_ref;
26524 }
26525
26526 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
26527         LDKChannelUpdate this_ptr_conv;
26528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26529         this_ptr_conv.is_owned = false;
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26531         LDKUnsignedChannelUpdate val_conv;
26532         val_conv.inner = (void*)(val & (~1));
26533         val_conv.is_owned = (val & 1) || (val == 0);
26534         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26535         val_conv = UnsignedChannelUpdate_clone(&val_conv);
26536         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
26537 }
26538
26539 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
26540         LDKSignature signature_arg_ref;
26541         CHECK(*((uint32_t*)signature_arg) == 64);
26542         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
26543         LDKUnsignedChannelUpdate contents_arg_conv;
26544         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26545         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26546         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26547         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
26548         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
26549         uint64_t ret_ref = 0;
26550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26553         ret_ref = (uint64_t)ret_var.inner;
26554         if (ret_var.is_owned) {
26555                 ret_ref |= 1;
26556         }
26557         return ret_ref;
26558 }
26559
26560 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
26561         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
26562 uint64_t ret_ref = 0;
26563 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26564 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26565 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26566 ret_ref = (uint64_t)ret_var.inner;
26567 if (ret_var.is_owned) {
26568         ret_ref |= 1;
26569 }
26570         return ret_ref;
26571 }
26572 int64_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
26573         LDKChannelUpdate arg_conv;
26574         arg_conv.inner = (void*)(arg & (~1));
26575         arg_conv.is_owned = false;
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26577         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
26578         return ret_val;
26579 }
26580
26581 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
26582         LDKChannelUpdate orig_conv;
26583         orig_conv.inner = (void*)(orig & (~1));
26584         orig_conv.is_owned = false;
26585         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26586         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
26587         uint64_t ret_ref = 0;
26588         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26589         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26591         ret_ref = (uint64_t)ret_var.inner;
26592         if (ret_var.is_owned) {
26593                 ret_ref |= 1;
26594         }
26595         return ret_ref;
26596 }
26597
26598 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_obj) {
26599         LDKQueryChannelRange this_obj_conv;
26600         this_obj_conv.inner = (void*)(this_obj & (~1));
26601         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26603         QueryChannelRange_free(this_obj_conv);
26604 }
26605
26606 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
26607         LDKQueryChannelRange this_ptr_conv;
26608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26609         this_ptr_conv.is_owned = false;
26610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26611         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26612         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
26613         return ret_arr;
26614 }
26615
26616 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26617         LDKQueryChannelRange this_ptr_conv;
26618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26619         this_ptr_conv.is_owned = false;
26620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26621         LDKThirtyTwoBytes val_ref;
26622         CHECK(*((uint32_t*)val) == 32);
26623         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26624         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26625 }
26626
26627 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
26628         LDKQueryChannelRange this_ptr_conv;
26629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26630         this_ptr_conv.is_owned = false;
26631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26632         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
26633         return ret_val;
26634 }
26635
26636 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26637         LDKQueryChannelRange this_ptr_conv;
26638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26639         this_ptr_conv.is_owned = false;
26640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26641         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
26642 }
26643
26644 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26645         LDKQueryChannelRange this_ptr_conv;
26646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26647         this_ptr_conv.is_owned = false;
26648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26649         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
26650         return ret_val;
26651 }
26652
26653 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26654         LDKQueryChannelRange this_ptr_conv;
26655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26656         this_ptr_conv.is_owned = false;
26657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26658         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26659 }
26660
26661 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
26662         LDKThirtyTwoBytes chain_hash_arg_ref;
26663         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26664         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26665         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
26666         uint64_t ret_ref = 0;
26667         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26668         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26670         ret_ref = (uint64_t)ret_var.inner;
26671         if (ret_var.is_owned) {
26672                 ret_ref |= 1;
26673         }
26674         return ret_ref;
26675 }
26676
26677 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
26678         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
26679 uint64_t ret_ref = 0;
26680 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26681 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26682 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26683 ret_ref = (uint64_t)ret_var.inner;
26684 if (ret_var.is_owned) {
26685         ret_ref |= 1;
26686 }
26687         return ret_ref;
26688 }
26689 int64_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
26690         LDKQueryChannelRange arg_conv;
26691         arg_conv.inner = (void*)(arg & (~1));
26692         arg_conv.is_owned = false;
26693         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26694         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
26695         return ret_val;
26696 }
26697
26698 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
26699         LDKQueryChannelRange orig_conv;
26700         orig_conv.inner = (void*)(orig & (~1));
26701         orig_conv.is_owned = false;
26702         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26703         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
26704         uint64_t ret_ref = 0;
26705         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26706         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26708         ret_ref = (uint64_t)ret_var.inner;
26709         if (ret_var.is_owned) {
26710                 ret_ref |= 1;
26711         }
26712         return ret_ref;
26713 }
26714
26715 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
26716         LDKReplyChannelRange this_obj_conv;
26717         this_obj_conv.inner = (void*)(this_obj & (~1));
26718         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26720         ReplyChannelRange_free(this_obj_conv);
26721 }
26722
26723 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
26724         LDKReplyChannelRange this_ptr_conv;
26725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26726         this_ptr_conv.is_owned = false;
26727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26728         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26729         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
26730         return ret_arr;
26731 }
26732
26733 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26734         LDKReplyChannelRange this_ptr_conv;
26735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26736         this_ptr_conv.is_owned = false;
26737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26738         LDKThirtyTwoBytes val_ref;
26739         CHECK(*((uint32_t*)val) == 32);
26740         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26741         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26742 }
26743
26744 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
26745         LDKReplyChannelRange this_ptr_conv;
26746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26747         this_ptr_conv.is_owned = false;
26748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26749         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
26750         return ret_val;
26751 }
26752
26753 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26754         LDKReplyChannelRange this_ptr_conv;
26755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26756         this_ptr_conv.is_owned = false;
26757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26758         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
26759 }
26760
26761 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26762         LDKReplyChannelRange this_ptr_conv;
26763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26764         this_ptr_conv.is_owned = false;
26765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26766         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
26767         return ret_val;
26768 }
26769
26770 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26771         LDKReplyChannelRange this_ptr_conv;
26772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26773         this_ptr_conv.is_owned = false;
26774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26775         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26776 }
26777
26778 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
26779         LDKReplyChannelRange this_ptr_conv;
26780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26781         this_ptr_conv.is_owned = false;
26782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26783         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
26784         return ret_val;
26785 }
26786
26787 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
26788         LDKReplyChannelRange this_ptr_conv;
26789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26790         this_ptr_conv.is_owned = false;
26791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26792         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
26793 }
26794
26795 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26796         LDKReplyChannelRange this_ptr_conv;
26797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26798         this_ptr_conv.is_owned = false;
26799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26800         LDKCVec_u64Z val_constr;
26801         val_constr.datalen = *((uint32_t*)val);
26802         if (val_constr.datalen > 0)
26803                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26804         else
26805                 val_constr.data = NULL;
26806         int64_t* val_vals = (int64_t*)(val + 4);
26807         for (size_t i = 0; i < val_constr.datalen; i++) {
26808                 int64_t val_conv_8 = val_vals[i];
26809                 val_constr.data[i] = val_conv_8;
26810         }
26811         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
26812 }
26813
26814 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg, jboolean sync_complete_arg, int64_tArray short_channel_ids_arg) {
26815         LDKThirtyTwoBytes chain_hash_arg_ref;
26816         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26817         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26818         LDKCVec_u64Z short_channel_ids_arg_constr;
26819         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
26820         if (short_channel_ids_arg_constr.datalen > 0)
26821                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26822         else
26823                 short_channel_ids_arg_constr.data = NULL;
26824         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
26825         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26826                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26827                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26828         }
26829         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
26830         uint64_t ret_ref = 0;
26831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26834         ret_ref = (uint64_t)ret_var.inner;
26835         if (ret_var.is_owned) {
26836                 ret_ref |= 1;
26837         }
26838         return ret_ref;
26839 }
26840
26841 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
26842         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
26843 uint64_t ret_ref = 0;
26844 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26845 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26846 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26847 ret_ref = (uint64_t)ret_var.inner;
26848 if (ret_var.is_owned) {
26849         ret_ref |= 1;
26850 }
26851         return ret_ref;
26852 }
26853 int64_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
26854         LDKReplyChannelRange arg_conv;
26855         arg_conv.inner = (void*)(arg & (~1));
26856         arg_conv.is_owned = false;
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26858         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
26859         return ret_val;
26860 }
26861
26862 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
26863         LDKReplyChannelRange orig_conv;
26864         orig_conv.inner = (void*)(orig & (~1));
26865         orig_conv.is_owned = false;
26866         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26867         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
26868         uint64_t ret_ref = 0;
26869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26872         ret_ref = (uint64_t)ret_var.inner;
26873         if (ret_var.is_owned) {
26874                 ret_ref |= 1;
26875         }
26876         return ret_ref;
26877 }
26878
26879 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
26880         LDKQueryShortChannelIds this_obj_conv;
26881         this_obj_conv.inner = (void*)(this_obj & (~1));
26882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26884         QueryShortChannelIds_free(this_obj_conv);
26885 }
26886
26887 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
26888         LDKQueryShortChannelIds this_ptr_conv;
26889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26890         this_ptr_conv.is_owned = false;
26891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26892         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
26893         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
26894         return ret_arr;
26895 }
26896
26897 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26898         LDKQueryShortChannelIds this_ptr_conv;
26899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26900         this_ptr_conv.is_owned = false;
26901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26902         LDKThirtyTwoBytes val_ref;
26903         CHECK(*((uint32_t*)val) == 32);
26904         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
26905         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
26906 }
26907
26908 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26909         LDKQueryShortChannelIds this_ptr_conv;
26910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26911         this_ptr_conv.is_owned = false;
26912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26913         LDKCVec_u64Z val_constr;
26914         val_constr.datalen = *((uint32_t*)val);
26915         if (val_constr.datalen > 0)
26916                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26917         else
26918                 val_constr.data = NULL;
26919         int64_t* val_vals = (int64_t*)(val + 4);
26920         for (size_t i = 0; i < val_constr.datalen; i++) {
26921                 int64_t val_conv_8 = val_vals[i];
26922                 val_constr.data[i] = val_conv_8;
26923         }
26924         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
26925 }
26926
26927 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
26928         LDKThirtyTwoBytes chain_hash_arg_ref;
26929         CHECK(*((uint32_t*)chain_hash_arg) == 32);
26930         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
26931         LDKCVec_u64Z short_channel_ids_arg_constr;
26932         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
26933         if (short_channel_ids_arg_constr.datalen > 0)
26934                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26935         else
26936                 short_channel_ids_arg_constr.data = NULL;
26937         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
26938         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26939                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26940                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26941         }
26942         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
26943         uint64_t ret_ref = 0;
26944         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26945         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26947         ret_ref = (uint64_t)ret_var.inner;
26948         if (ret_var.is_owned) {
26949                 ret_ref |= 1;
26950         }
26951         return ret_ref;
26952 }
26953
26954 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
26955         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
26956 uint64_t ret_ref = 0;
26957 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26958 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26959 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26960 ret_ref = (uint64_t)ret_var.inner;
26961 if (ret_var.is_owned) {
26962         ret_ref |= 1;
26963 }
26964         return ret_ref;
26965 }
26966 int64_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
26967         LDKQueryShortChannelIds arg_conv;
26968         arg_conv.inner = (void*)(arg & (~1));
26969         arg_conv.is_owned = false;
26970         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26971         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
26972         return ret_val;
26973 }
26974
26975 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
26976         LDKQueryShortChannelIds orig_conv;
26977         orig_conv.inner = (void*)(orig & (~1));
26978         orig_conv.is_owned = false;
26979         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26980         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
26981         uint64_t ret_ref = 0;
26982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26985         ret_ref = (uint64_t)ret_var.inner;
26986         if (ret_var.is_owned) {
26987                 ret_ref |= 1;
26988         }
26989         return ret_ref;
26990 }
26991
26992 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
26993         LDKReplyShortChannelIdsEnd this_obj_conv;
26994         this_obj_conv.inner = (void*)(this_obj & (~1));
26995         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26997         ReplyShortChannelIdsEnd_free(this_obj_conv);
26998 }
26999
27000 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
27001         LDKReplyShortChannelIdsEnd this_ptr_conv;
27002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27003         this_ptr_conv.is_owned = false;
27004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27005         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
27006         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
27007         return ret_arr;
27008 }
27009
27010 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
27011         LDKReplyShortChannelIdsEnd this_ptr_conv;
27012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27013         this_ptr_conv.is_owned = false;
27014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27015         LDKThirtyTwoBytes val_ref;
27016         CHECK(*((uint32_t*)val) == 32);
27017         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
27018         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
27019 }
27020
27021 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
27022         LDKReplyShortChannelIdsEnd this_ptr_conv;
27023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27024         this_ptr_conv.is_owned = false;
27025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27026         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
27027         return ret_val;
27028 }
27029
27030 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
27031         LDKReplyShortChannelIdsEnd this_ptr_conv;
27032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27033         this_ptr_conv.is_owned = false;
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27035         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
27036 }
27037
27038 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
27039         LDKThirtyTwoBytes chain_hash_arg_ref;
27040         CHECK(*((uint32_t*)chain_hash_arg) == 32);
27041         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
27042         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
27043         uint64_t ret_ref = 0;
27044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27047         ret_ref = (uint64_t)ret_var.inner;
27048         if (ret_var.is_owned) {
27049                 ret_ref |= 1;
27050         }
27051         return ret_ref;
27052 }
27053
27054 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
27055         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
27056 uint64_t ret_ref = 0;
27057 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27058 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27059 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27060 ret_ref = (uint64_t)ret_var.inner;
27061 if (ret_var.is_owned) {
27062         ret_ref |= 1;
27063 }
27064         return ret_ref;
27065 }
27066 int64_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
27067         LDKReplyShortChannelIdsEnd arg_conv;
27068         arg_conv.inner = (void*)(arg & (~1));
27069         arg_conv.is_owned = false;
27070         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27071         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
27072         return ret_val;
27073 }
27074
27075 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
27076         LDKReplyShortChannelIdsEnd orig_conv;
27077         orig_conv.inner = (void*)(orig & (~1));
27078         orig_conv.is_owned = false;
27079         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27080         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
27081         uint64_t ret_ref = 0;
27082         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27083         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27085         ret_ref = (uint64_t)ret_var.inner;
27086         if (ret_var.is_owned) {
27087                 ret_ref |= 1;
27088         }
27089         return ret_ref;
27090 }
27091
27092 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
27093         LDKGossipTimestampFilter this_obj_conv;
27094         this_obj_conv.inner = (void*)(this_obj & (~1));
27095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27097         GossipTimestampFilter_free(this_obj_conv);
27098 }
27099
27100 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
27101         LDKGossipTimestampFilter this_ptr_conv;
27102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27103         this_ptr_conv.is_owned = false;
27104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27105         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
27106         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
27107         return ret_arr;
27108 }
27109
27110 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
27111         LDKGossipTimestampFilter this_ptr_conv;
27112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27113         this_ptr_conv.is_owned = false;
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27115         LDKThirtyTwoBytes val_ref;
27116         CHECK(*((uint32_t*)val) == 32);
27117         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
27118         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
27119 }
27120
27121 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
27122         LDKGossipTimestampFilter this_ptr_conv;
27123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27124         this_ptr_conv.is_owned = false;
27125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27126         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
27127         return ret_val;
27128 }
27129
27130 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
27131         LDKGossipTimestampFilter this_ptr_conv;
27132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27133         this_ptr_conv.is_owned = false;
27134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27135         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
27136 }
27137
27138 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
27139         LDKGossipTimestampFilter this_ptr_conv;
27140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27141         this_ptr_conv.is_owned = false;
27142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27143         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
27144         return ret_val;
27145 }
27146
27147 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
27148         LDKGossipTimestampFilter this_ptr_conv;
27149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27150         this_ptr_conv.is_owned = false;
27151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27152         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
27153 }
27154
27155 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
27156         LDKThirtyTwoBytes chain_hash_arg_ref;
27157         CHECK(*((uint32_t*)chain_hash_arg) == 32);
27158         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
27159         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
27160         uint64_t ret_ref = 0;
27161         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27162         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27164         ret_ref = (uint64_t)ret_var.inner;
27165         if (ret_var.is_owned) {
27166                 ret_ref |= 1;
27167         }
27168         return ret_ref;
27169 }
27170
27171 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
27172         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
27173 uint64_t ret_ref = 0;
27174 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27175 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27176 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27177 ret_ref = (uint64_t)ret_var.inner;
27178 if (ret_var.is_owned) {
27179         ret_ref |= 1;
27180 }
27181         return ret_ref;
27182 }
27183 int64_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
27184         LDKGossipTimestampFilter arg_conv;
27185         arg_conv.inner = (void*)(arg & (~1));
27186         arg_conv.is_owned = false;
27187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27188         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
27189         return ret_val;
27190 }
27191
27192 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
27193         LDKGossipTimestampFilter orig_conv;
27194         orig_conv.inner = (void*)(orig & (~1));
27195         orig_conv.is_owned = false;
27196         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27197         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
27198         uint64_t ret_ref = 0;
27199         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27200         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27202         ret_ref = (uint64_t)ret_var.inner;
27203         if (ret_var.is_owned) {
27204                 ret_ref |= 1;
27205         }
27206         return ret_ref;
27207 }
27208
27209 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
27210         if ((this_ptr & 1) != 0) return;
27211         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27212         CHECK_ACCESS(this_ptr_ptr);
27213         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
27214         FREE((void*)this_ptr);
27215         ErrorAction_free(this_ptr_conv);
27216 }
27217
27218 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
27219         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27220         *ret_copy = ErrorAction_clone(arg);
27221 uint64_t ret_ref = (uint64_t)ret_copy;
27222         return ret_ref;
27223 }
27224 int64_t  __attribute__((visibility("default"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
27225         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
27226         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
27227         return ret_val;
27228 }
27229
27230 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
27231         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
27232         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27233         *ret_copy = ErrorAction_clone(orig_conv);
27234         uint64_t ret_ref = (uint64_t)ret_copy;
27235         return ret_ref;
27236 }
27237
27238 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
27239         LDKErrorMessage msg_conv;
27240         msg_conv.inner = (void*)(msg & (~1));
27241         msg_conv.is_owned = (msg & 1) || (msg == 0);
27242         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27243         msg_conv = ErrorMessage_clone(&msg_conv);
27244         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27245         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
27246         uint64_t ret_ref = (uint64_t)ret_copy;
27247         return ret_ref;
27248 }
27249
27250 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_error() {
27251         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27252         *ret_copy = ErrorAction_ignore_error();
27253         uint64_t ret_ref = (uint64_t)ret_copy;
27254         return ret_ref;
27255 }
27256
27257 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
27258         LDKLevel a_conv = LDKLevel_from_js(a);
27259         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27260         *ret_copy = ErrorAction_ignore_and_log(a_conv);
27261         uint64_t ret_ref = (uint64_t)ret_copy;
27262         return ret_ref;
27263 }
27264
27265 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_ignore_duplicate_gossip() {
27266         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27267         *ret_copy = ErrorAction_ignore_duplicate_gossip();
27268         uint64_t ret_ref = (uint64_t)ret_copy;
27269         return ret_ref;
27270 }
27271
27272 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_send_error_message(uint32_t msg) {
27273         LDKErrorMessage msg_conv;
27274         msg_conv.inner = (void*)(msg & (~1));
27275         msg_conv.is_owned = (msg & 1) || (msg == 0);
27276         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27277         msg_conv = ErrorMessage_clone(&msg_conv);
27278         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27279         *ret_copy = ErrorAction_send_error_message(msg_conv);
27280         uint64_t ret_ref = (uint64_t)ret_copy;
27281         return ret_ref;
27282 }
27283
27284 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_obj) {
27285         LDKLightningError this_obj_conv;
27286         this_obj_conv.inner = (void*)(this_obj & (~1));
27287         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27289         LightningError_free(this_obj_conv);
27290 }
27291
27292 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
27293         LDKLightningError this_ptr_conv;
27294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27295         this_ptr_conv.is_owned = false;
27296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27297         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
27298         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27299         Str_free(ret_str);
27300         return ret_conv;
27301 }
27302
27303 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
27304         LDKLightningError this_ptr_conv;
27305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27306         this_ptr_conv.is_owned = false;
27307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27308         LDKStr val_conv = str_ref_to_owned_c(val);
27309         LightningError_set_err(&this_ptr_conv, val_conv);
27310 }
27311
27312 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
27313         LDKLightningError this_ptr_conv;
27314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27315         this_ptr_conv.is_owned = false;
27316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27317         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27318         *ret_copy = LightningError_get_action(&this_ptr_conv);
27319         uint64_t ret_ref = (uint64_t)ret_copy;
27320         return ret_ref;
27321 }
27322
27323 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
27324         LDKLightningError this_ptr_conv;
27325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27326         this_ptr_conv.is_owned = false;
27327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27328         void* val_ptr = (void*)(((uint64_t)val) & ~1);
27329         CHECK_ACCESS(val_ptr);
27330         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
27331         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
27332         LightningError_set_action(&this_ptr_conv, val_conv);
27333 }
27334
27335 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
27336         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
27337         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
27338         CHECK_ACCESS(action_arg_ptr);
27339         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
27340         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
27341         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
27342         uint64_t ret_ref = 0;
27343         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27344         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27346         ret_ref = (uint64_t)ret_var.inner;
27347         if (ret_var.is_owned) {
27348                 ret_ref |= 1;
27349         }
27350         return ret_ref;
27351 }
27352
27353 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
27354         LDKLightningError ret_var = LightningError_clone(arg);
27355 uint64_t ret_ref = 0;
27356 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27357 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27358 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27359 ret_ref = (uint64_t)ret_var.inner;
27360 if (ret_var.is_owned) {
27361         ret_ref |= 1;
27362 }
27363         return ret_ref;
27364 }
27365 int64_t  __attribute__((visibility("default"))) TS_LightningError_clone_ptr(uint32_t arg) {
27366         LDKLightningError arg_conv;
27367         arg_conv.inner = (void*)(arg & (~1));
27368         arg_conv.is_owned = false;
27369         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27370         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
27371         return ret_val;
27372 }
27373
27374 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
27375         LDKLightningError orig_conv;
27376         orig_conv.inner = (void*)(orig & (~1));
27377         orig_conv.is_owned = false;
27378         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27379         LDKLightningError ret_var = LightningError_clone(&orig_conv);
27380         uint64_t ret_ref = 0;
27381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27384         ret_ref = (uint64_t)ret_var.inner;
27385         if (ret_var.is_owned) {
27386                 ret_ref |= 1;
27387         }
27388         return ret_ref;
27389 }
27390
27391 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
27392         LDKCommitmentUpdate this_obj_conv;
27393         this_obj_conv.inner = (void*)(this_obj & (~1));
27394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27396         CommitmentUpdate_free(this_obj_conv);
27397 }
27398
27399 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
27400         LDKCommitmentUpdate this_ptr_conv;
27401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27402         this_ptr_conv.is_owned = false;
27403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27404         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
27405         uint32_tArray ret_arr = NULL;
27406         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27407         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27408         for (size_t p = 0; p < ret_var.datalen; p++) {
27409                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
27410                 uint64_t ret_conv_15_ref = 0;
27411                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27412                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27413                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
27414                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
27415                 if (ret_conv_15_var.is_owned) {
27416                         ret_conv_15_ref |= 1;
27417                 }
27418                 ret_arr_ptr[p] = ret_conv_15_ref;
27419         }
27420         
27421         FREE(ret_var.data);
27422         return ret_arr;
27423 }
27424
27425 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
27426         LDKCommitmentUpdate this_ptr_conv;
27427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27428         this_ptr_conv.is_owned = false;
27429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27430         LDKCVec_UpdateAddHTLCZ val_constr;
27431         val_constr.datalen = *((uint32_t*)val);
27432         if (val_constr.datalen > 0)
27433                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27434         else
27435                 val_constr.data = NULL;
27436         uint32_t* val_vals = (uint32_t*)(val + 4);
27437         for (size_t p = 0; p < val_constr.datalen; p++) {
27438                 uint32_t val_conv_15 = val_vals[p];
27439                 LDKUpdateAddHTLC val_conv_15_conv;
27440                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
27441                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
27442                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
27443                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
27444                 val_constr.data[p] = val_conv_15_conv;
27445         }
27446         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
27447 }
27448
27449 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
27450         LDKCommitmentUpdate this_ptr_conv;
27451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27452         this_ptr_conv.is_owned = false;
27453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27454         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
27455         uint32_tArray ret_arr = NULL;
27456         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27457         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27458         for (size_t t = 0; t < ret_var.datalen; t++) {
27459                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
27460                 uint64_t ret_conv_19_ref = 0;
27461                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27462                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27463                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
27464                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
27465                 if (ret_conv_19_var.is_owned) {
27466                         ret_conv_19_ref |= 1;
27467                 }
27468                 ret_arr_ptr[t] = ret_conv_19_ref;
27469         }
27470         
27471         FREE(ret_var.data);
27472         return ret_arr;
27473 }
27474
27475 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
27476         LDKCommitmentUpdate this_ptr_conv;
27477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27478         this_ptr_conv.is_owned = false;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27480         LDKCVec_UpdateFulfillHTLCZ val_constr;
27481         val_constr.datalen = *((uint32_t*)val);
27482         if (val_constr.datalen > 0)
27483                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27484         else
27485                 val_constr.data = NULL;
27486         uint32_t* val_vals = (uint32_t*)(val + 4);
27487         for (size_t t = 0; t < val_constr.datalen; t++) {
27488                 uint32_t val_conv_19 = val_vals[t];
27489                 LDKUpdateFulfillHTLC val_conv_19_conv;
27490                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
27491                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
27492                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
27493                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
27494                 val_constr.data[t] = val_conv_19_conv;
27495         }
27496         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
27497 }
27498
27499 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
27500         LDKCommitmentUpdate this_ptr_conv;
27501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27502         this_ptr_conv.is_owned = false;
27503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27504         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
27505         uint32_tArray ret_arr = NULL;
27506         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27507         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27508         for (size_t q = 0; q < ret_var.datalen; q++) {
27509                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
27510                 uint64_t ret_conv_16_ref = 0;
27511                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27512                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27513                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27514                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
27515                 if (ret_conv_16_var.is_owned) {
27516                         ret_conv_16_ref |= 1;
27517                 }
27518                 ret_arr_ptr[q] = ret_conv_16_ref;
27519         }
27520         
27521         FREE(ret_var.data);
27522         return ret_arr;
27523 }
27524
27525 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
27526         LDKCommitmentUpdate this_ptr_conv;
27527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27528         this_ptr_conv.is_owned = false;
27529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27530         LDKCVec_UpdateFailHTLCZ val_constr;
27531         val_constr.datalen = *((uint32_t*)val);
27532         if (val_constr.datalen > 0)
27533                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27534         else
27535                 val_constr.data = NULL;
27536         uint32_t* val_vals = (uint32_t*)(val + 4);
27537         for (size_t q = 0; q < val_constr.datalen; q++) {
27538                 uint32_t val_conv_16 = val_vals[q];
27539                 LDKUpdateFailHTLC val_conv_16_conv;
27540                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
27541                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
27542                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
27543                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
27544                 val_constr.data[q] = val_conv_16_conv;
27545         }
27546         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
27547 }
27548
27549 uint32_tArray  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
27550         LDKCommitmentUpdate this_ptr_conv;
27551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27552         this_ptr_conv.is_owned = false;
27553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27554         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
27555         uint32_tArray ret_arr = NULL;
27556         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
27557         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
27558         for (size_t z = 0; z < ret_var.datalen; z++) {
27559                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
27560                 uint64_t ret_conv_25_ref = 0;
27561                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27562                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27563                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
27564                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
27565                 if (ret_conv_25_var.is_owned) {
27566                         ret_conv_25_ref |= 1;
27567                 }
27568                 ret_arr_ptr[z] = ret_conv_25_ref;
27569         }
27570         
27571         FREE(ret_var.data);
27572         return ret_arr;
27573 }
27574
27575 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
27576         LDKCommitmentUpdate this_ptr_conv;
27577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27578         this_ptr_conv.is_owned = false;
27579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27580         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
27581         val_constr.datalen = *((uint32_t*)val);
27582         if (val_constr.datalen > 0)
27583                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27584         else
27585                 val_constr.data = NULL;
27586         uint32_t* val_vals = (uint32_t*)(val + 4);
27587         for (size_t z = 0; z < val_constr.datalen; z++) {
27588                 uint32_t val_conv_25 = val_vals[z];
27589                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
27590                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
27591                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
27592                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
27593                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
27594                 val_constr.data[z] = val_conv_25_conv;
27595         }
27596         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
27597 }
27598
27599 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
27600         LDKCommitmentUpdate this_ptr_conv;
27601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27602         this_ptr_conv.is_owned = false;
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27604         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
27605         uint64_t ret_ref = 0;
27606         if ((uint64_t)ret_var.inner > 4096) {
27607                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27608                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27610                 ret_ref = (uint64_t)ret_var.inner;
27611                 if (ret_var.is_owned) {
27612                         ret_ref |= 1;
27613                 }
27614         }
27615         return ret_ref;
27616 }
27617
27618 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
27619         LDKCommitmentUpdate this_ptr_conv;
27620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27621         this_ptr_conv.is_owned = false;
27622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27623         LDKUpdateFee val_conv;
27624         val_conv.inner = (void*)(val & (~1));
27625         val_conv.is_owned = (val & 1) || (val == 0);
27626         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27627         val_conv = UpdateFee_clone(&val_conv);
27628         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
27629 }
27630
27631 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
27632         LDKCommitmentUpdate this_ptr_conv;
27633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27634         this_ptr_conv.is_owned = false;
27635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27636         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
27637         uint64_t ret_ref = 0;
27638         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27639         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27641         ret_ref = (uint64_t)ret_var.inner;
27642         if (ret_var.is_owned) {
27643                 ret_ref |= 1;
27644         }
27645         return ret_ref;
27646 }
27647
27648 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
27649         LDKCommitmentUpdate this_ptr_conv;
27650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27651         this_ptr_conv.is_owned = false;
27652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27653         LDKCommitmentSigned val_conv;
27654         val_conv.inner = (void*)(val & (~1));
27655         val_conv.is_owned = (val & 1) || (val == 0);
27656         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27657         val_conv = CommitmentSigned_clone(&val_conv);
27658         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
27659 }
27660
27661 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_new(uint32_tArray update_add_htlcs_arg, uint32_tArray update_fulfill_htlcs_arg, uint32_tArray update_fail_htlcs_arg, uint32_tArray update_fail_malformed_htlcs_arg, uint32_t update_fee_arg, uint32_t commitment_signed_arg) {
27662         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
27663         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
27664         if (update_add_htlcs_arg_constr.datalen > 0)
27665                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27666         else
27667                 update_add_htlcs_arg_constr.data = NULL;
27668         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
27669         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
27670                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
27671                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
27672                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
27673                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
27674                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
27675                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
27676                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
27677         }
27678         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
27679         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
27680         if (update_fulfill_htlcs_arg_constr.datalen > 0)
27681                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27682         else
27683                 update_fulfill_htlcs_arg_constr.data = NULL;
27684         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
27685         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
27686                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
27687                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
27688                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
27689                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
27690                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
27691                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
27692                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
27693         }
27694         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
27695         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
27696         if (update_fail_htlcs_arg_constr.datalen > 0)
27697                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27698         else
27699                 update_fail_htlcs_arg_constr.data = NULL;
27700         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
27701         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
27702                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
27703                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
27704                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
27705                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
27706                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
27707                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
27708                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
27709         }
27710         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
27711         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
27712         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
27713                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27714         else
27715                 update_fail_malformed_htlcs_arg_constr.data = NULL;
27716         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
27717         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
27718                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
27719                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
27720                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
27721                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = (update_fail_malformed_htlcs_arg_conv_25 & 1) || (update_fail_malformed_htlcs_arg_conv_25 == 0);
27722                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
27723                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
27724                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
27725         }
27726         LDKUpdateFee update_fee_arg_conv;
27727         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
27728         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
27729         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
27730         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
27731         LDKCommitmentSigned commitment_signed_arg_conv;
27732         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
27733         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
27734         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
27735         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
27736         LDKCommitmentUpdate ret_var = CommitmentUpdate_new(update_add_htlcs_arg_constr, update_fulfill_htlcs_arg_constr, update_fail_htlcs_arg_constr, update_fail_malformed_htlcs_arg_constr, update_fee_arg_conv, commitment_signed_arg_conv);
27737         uint64_t ret_ref = 0;
27738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27741         ret_ref = (uint64_t)ret_var.inner;
27742         if (ret_var.is_owned) {
27743                 ret_ref |= 1;
27744         }
27745         return ret_ref;
27746 }
27747
27748 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
27749         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
27750 uint64_t ret_ref = 0;
27751 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27752 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27753 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27754 ret_ref = (uint64_t)ret_var.inner;
27755 if (ret_var.is_owned) {
27756         ret_ref |= 1;
27757 }
27758         return ret_ref;
27759 }
27760 int64_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
27761         LDKCommitmentUpdate arg_conv;
27762         arg_conv.inner = (void*)(arg & (~1));
27763         arg_conv.is_owned = false;
27764         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27765         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
27766         return ret_val;
27767 }
27768
27769 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
27770         LDKCommitmentUpdate orig_conv;
27771         orig_conv.inner = (void*)(orig & (~1));
27772         orig_conv.is_owned = false;
27773         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27774         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
27775         uint64_t ret_ref = 0;
27776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27779         ret_ref = (uint64_t)ret_var.inner;
27780         if (ret_var.is_owned) {
27781                 ret_ref |= 1;
27782         }
27783         return ret_ref;
27784 }
27785
27786 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
27787         if ((this_ptr & 1) != 0) return;
27788         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27789         CHECK_ACCESS(this_ptr_ptr);
27790         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
27791         FREE((void*)this_ptr);
27792         ChannelMessageHandler_free(this_ptr_conv);
27793 }
27794
27795 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
27796         if ((this_ptr & 1) != 0) return;
27797         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
27798         CHECK_ACCESS(this_ptr_ptr);
27799         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
27800         FREE((void*)this_ptr);
27801         RoutingMessageHandler_free(this_ptr_conv);
27802 }
27803
27804 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
27805         LDKAcceptChannel obj_conv;
27806         obj_conv.inner = (void*)(obj & (~1));
27807         obj_conv.is_owned = false;
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27809         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
27810         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27811         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27812         CVec_u8Z_free(ret_var);
27813         return ret_arr;
27814 }
27815
27816 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
27817         LDKu8slice ser_ref;
27818         ser_ref.datalen = *((uint32_t*)ser);
27819         ser_ref.data = (int8_t*)(ser + 4);
27820         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
27821         *ret_conv = AcceptChannel_read(ser_ref);
27822         return (uint64_t)ret_conv;
27823 }
27824
27825 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
27826         LDKAnnouncementSignatures obj_conv;
27827         obj_conv.inner = (void*)(obj & (~1));
27828         obj_conv.is_owned = false;
27829         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27830         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
27831         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27832         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27833         CVec_u8Z_free(ret_var);
27834         return ret_arr;
27835 }
27836
27837 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
27838         LDKu8slice ser_ref;
27839         ser_ref.datalen = *((uint32_t*)ser);
27840         ser_ref.data = (int8_t*)(ser + 4);
27841         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
27842         *ret_conv = AnnouncementSignatures_read(ser_ref);
27843         return (uint64_t)ret_conv;
27844 }
27845
27846 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
27847         LDKChannelReestablish obj_conv;
27848         obj_conv.inner = (void*)(obj & (~1));
27849         obj_conv.is_owned = false;
27850         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27851         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
27852         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27853         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27854         CVec_u8Z_free(ret_var);
27855         return ret_arr;
27856 }
27857
27858 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
27859         LDKu8slice ser_ref;
27860         ser_ref.datalen = *((uint32_t*)ser);
27861         ser_ref.data = (int8_t*)(ser + 4);
27862         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
27863         *ret_conv = ChannelReestablish_read(ser_ref);
27864         return (uint64_t)ret_conv;
27865 }
27866
27867 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
27868         LDKClosingSigned obj_conv;
27869         obj_conv.inner = (void*)(obj & (~1));
27870         obj_conv.is_owned = false;
27871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27872         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
27873         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27874         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27875         CVec_u8Z_free(ret_var);
27876         return ret_arr;
27877 }
27878
27879 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
27880         LDKu8slice ser_ref;
27881         ser_ref.datalen = *((uint32_t*)ser);
27882         ser_ref.data = (int8_t*)(ser + 4);
27883         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
27884         *ret_conv = ClosingSigned_read(ser_ref);
27885         return (uint64_t)ret_conv;
27886 }
27887
27888 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
27889         LDKClosingSignedFeeRange obj_conv;
27890         obj_conv.inner = (void*)(obj & (~1));
27891         obj_conv.is_owned = false;
27892         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27893         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
27894         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27895         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27896         CVec_u8Z_free(ret_var);
27897         return ret_arr;
27898 }
27899
27900 uint32_t  __attribute__((visibility("default"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
27901         LDKu8slice ser_ref;
27902         ser_ref.datalen = *((uint32_t*)ser);
27903         ser_ref.data = (int8_t*)(ser + 4);
27904         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
27905         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
27906         return (uint64_t)ret_conv;
27907 }
27908
27909 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
27910         LDKCommitmentSigned obj_conv;
27911         obj_conv.inner = (void*)(obj & (~1));
27912         obj_conv.is_owned = false;
27913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27914         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
27915         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27916         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27917         CVec_u8Z_free(ret_var);
27918         return ret_arr;
27919 }
27920
27921 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
27922         LDKu8slice ser_ref;
27923         ser_ref.datalen = *((uint32_t*)ser);
27924         ser_ref.data = (int8_t*)(ser + 4);
27925         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
27926         *ret_conv = CommitmentSigned_read(ser_ref);
27927         return (uint64_t)ret_conv;
27928 }
27929
27930 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
27931         LDKFundingCreated obj_conv;
27932         obj_conv.inner = (void*)(obj & (~1));
27933         obj_conv.is_owned = false;
27934         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27935         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
27936         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27937         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27938         CVec_u8Z_free(ret_var);
27939         return ret_arr;
27940 }
27941
27942 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
27943         LDKu8slice ser_ref;
27944         ser_ref.datalen = *((uint32_t*)ser);
27945         ser_ref.data = (int8_t*)(ser + 4);
27946         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
27947         *ret_conv = FundingCreated_read(ser_ref);
27948         return (uint64_t)ret_conv;
27949 }
27950
27951 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
27952         LDKFundingSigned obj_conv;
27953         obj_conv.inner = (void*)(obj & (~1));
27954         obj_conv.is_owned = false;
27955         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27956         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
27957         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27958         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27959         CVec_u8Z_free(ret_var);
27960         return ret_arr;
27961 }
27962
27963 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
27964         LDKu8slice ser_ref;
27965         ser_ref.datalen = *((uint32_t*)ser);
27966         ser_ref.data = (int8_t*)(ser + 4);
27967         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
27968         *ret_conv = FundingSigned_read(ser_ref);
27969         return (uint64_t)ret_conv;
27970 }
27971
27972 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
27973         LDKFundingLocked obj_conv;
27974         obj_conv.inner = (void*)(obj & (~1));
27975         obj_conv.is_owned = false;
27976         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27977         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
27978         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
27979         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
27980         CVec_u8Z_free(ret_var);
27981         return ret_arr;
27982 }
27983
27984 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
27985         LDKu8slice ser_ref;
27986         ser_ref.datalen = *((uint32_t*)ser);
27987         ser_ref.data = (int8_t*)(ser + 4);
27988         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
27989         *ret_conv = FundingLocked_read(ser_ref);
27990         return (uint64_t)ret_conv;
27991 }
27992
27993 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
27994         LDKInit obj_conv;
27995         obj_conv.inner = (void*)(obj & (~1));
27996         obj_conv.is_owned = false;
27997         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27998         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
27999         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28000         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28001         CVec_u8Z_free(ret_var);
28002         return ret_arr;
28003 }
28004
28005 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
28006         LDKu8slice ser_ref;
28007         ser_ref.datalen = *((uint32_t*)ser);
28008         ser_ref.data = (int8_t*)(ser + 4);
28009         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
28010         *ret_conv = Init_read(ser_ref);
28011         return (uint64_t)ret_conv;
28012 }
28013
28014 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
28015         LDKOpenChannel obj_conv;
28016         obj_conv.inner = (void*)(obj & (~1));
28017         obj_conv.is_owned = false;
28018         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28019         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
28020         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28021         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28022         CVec_u8Z_free(ret_var);
28023         return ret_arr;
28024 }
28025
28026 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
28027         LDKu8slice ser_ref;
28028         ser_ref.datalen = *((uint32_t*)ser);
28029         ser_ref.data = (int8_t*)(ser + 4);
28030         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
28031         *ret_conv = OpenChannel_read(ser_ref);
28032         return (uint64_t)ret_conv;
28033 }
28034
28035 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
28036         LDKRevokeAndACK obj_conv;
28037         obj_conv.inner = (void*)(obj & (~1));
28038         obj_conv.is_owned = false;
28039         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28040         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
28041         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28042         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28043         CVec_u8Z_free(ret_var);
28044         return ret_arr;
28045 }
28046
28047 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
28048         LDKu8slice ser_ref;
28049         ser_ref.datalen = *((uint32_t*)ser);
28050         ser_ref.data = (int8_t*)(ser + 4);
28051         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
28052         *ret_conv = RevokeAndACK_read(ser_ref);
28053         return (uint64_t)ret_conv;
28054 }
28055
28056 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
28057         LDKShutdown obj_conv;
28058         obj_conv.inner = (void*)(obj & (~1));
28059         obj_conv.is_owned = false;
28060         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28061         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
28062         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28063         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28064         CVec_u8Z_free(ret_var);
28065         return ret_arr;
28066 }
28067
28068 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
28069         LDKu8slice ser_ref;
28070         ser_ref.datalen = *((uint32_t*)ser);
28071         ser_ref.data = (int8_t*)(ser + 4);
28072         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
28073         *ret_conv = Shutdown_read(ser_ref);
28074         return (uint64_t)ret_conv;
28075 }
28076
28077 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
28078         LDKUpdateFailHTLC obj_conv;
28079         obj_conv.inner = (void*)(obj & (~1));
28080         obj_conv.is_owned = false;
28081         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28082         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
28083         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28084         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28085         CVec_u8Z_free(ret_var);
28086         return ret_arr;
28087 }
28088
28089 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
28090         LDKu8slice ser_ref;
28091         ser_ref.datalen = *((uint32_t*)ser);
28092         ser_ref.data = (int8_t*)(ser + 4);
28093         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
28094         *ret_conv = UpdateFailHTLC_read(ser_ref);
28095         return (uint64_t)ret_conv;
28096 }
28097
28098 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
28099         LDKUpdateFailMalformedHTLC obj_conv;
28100         obj_conv.inner = (void*)(obj & (~1));
28101         obj_conv.is_owned = false;
28102         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28103         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
28104         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28105         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28106         CVec_u8Z_free(ret_var);
28107         return ret_arr;
28108 }
28109
28110 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
28111         LDKu8slice ser_ref;
28112         ser_ref.datalen = *((uint32_t*)ser);
28113         ser_ref.data = (int8_t*)(ser + 4);
28114         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
28115         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
28116         return (uint64_t)ret_conv;
28117 }
28118
28119 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
28120         LDKUpdateFee obj_conv;
28121         obj_conv.inner = (void*)(obj & (~1));
28122         obj_conv.is_owned = false;
28123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28124         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
28125         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28126         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28127         CVec_u8Z_free(ret_var);
28128         return ret_arr;
28129 }
28130
28131 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
28132         LDKu8slice ser_ref;
28133         ser_ref.datalen = *((uint32_t*)ser);
28134         ser_ref.data = (int8_t*)(ser + 4);
28135         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
28136         *ret_conv = UpdateFee_read(ser_ref);
28137         return (uint64_t)ret_conv;
28138 }
28139
28140 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
28141         LDKUpdateFulfillHTLC obj_conv;
28142         obj_conv.inner = (void*)(obj & (~1));
28143         obj_conv.is_owned = false;
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28145         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
28146         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28147         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28148         CVec_u8Z_free(ret_var);
28149         return ret_arr;
28150 }
28151
28152 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
28153         LDKu8slice ser_ref;
28154         ser_ref.datalen = *((uint32_t*)ser);
28155         ser_ref.data = (int8_t*)(ser + 4);
28156         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
28157         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
28158         return (uint64_t)ret_conv;
28159 }
28160
28161 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
28162         LDKUpdateAddHTLC obj_conv;
28163         obj_conv.inner = (void*)(obj & (~1));
28164         obj_conv.is_owned = false;
28165         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28166         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
28167         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28168         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28169         CVec_u8Z_free(ret_var);
28170         return ret_arr;
28171 }
28172
28173 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
28174         LDKu8slice ser_ref;
28175         ser_ref.datalen = *((uint32_t*)ser);
28176         ser_ref.data = (int8_t*)(ser + 4);
28177         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
28178         *ret_conv = UpdateAddHTLC_read(ser_ref);
28179         return (uint64_t)ret_conv;
28180 }
28181
28182 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
28183         LDKPing obj_conv;
28184         obj_conv.inner = (void*)(obj & (~1));
28185         obj_conv.is_owned = false;
28186         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28187         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
28188         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28189         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28190         CVec_u8Z_free(ret_var);
28191         return ret_arr;
28192 }
28193
28194 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
28195         LDKu8slice ser_ref;
28196         ser_ref.datalen = *((uint32_t*)ser);
28197         ser_ref.data = (int8_t*)(ser + 4);
28198         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
28199         *ret_conv = Ping_read(ser_ref);
28200         return (uint64_t)ret_conv;
28201 }
28202
28203 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
28204         LDKPong obj_conv;
28205         obj_conv.inner = (void*)(obj & (~1));
28206         obj_conv.is_owned = false;
28207         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28208         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
28209         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28210         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28211         CVec_u8Z_free(ret_var);
28212         return ret_arr;
28213 }
28214
28215 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
28216         LDKu8slice ser_ref;
28217         ser_ref.datalen = *((uint32_t*)ser);
28218         ser_ref.data = (int8_t*)(ser + 4);
28219         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
28220         *ret_conv = Pong_read(ser_ref);
28221         return (uint64_t)ret_conv;
28222 }
28223
28224 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
28225         LDKUnsignedChannelAnnouncement obj_conv;
28226         obj_conv.inner = (void*)(obj & (~1));
28227         obj_conv.is_owned = false;
28228         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28229         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
28230         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28231         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28232         CVec_u8Z_free(ret_var);
28233         return ret_arr;
28234 }
28235
28236 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
28237         LDKu8slice ser_ref;
28238         ser_ref.datalen = *((uint32_t*)ser);
28239         ser_ref.data = (int8_t*)(ser + 4);
28240         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
28241         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
28242         return (uint64_t)ret_conv;
28243 }
28244
28245 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
28246         LDKChannelAnnouncement obj_conv;
28247         obj_conv.inner = (void*)(obj & (~1));
28248         obj_conv.is_owned = false;
28249         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28250         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
28251         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28252         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28253         CVec_u8Z_free(ret_var);
28254         return ret_arr;
28255 }
28256
28257 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
28258         LDKu8slice ser_ref;
28259         ser_ref.datalen = *((uint32_t*)ser);
28260         ser_ref.data = (int8_t*)(ser + 4);
28261         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
28262         *ret_conv = ChannelAnnouncement_read(ser_ref);
28263         return (uint64_t)ret_conv;
28264 }
28265
28266 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
28267         LDKUnsignedChannelUpdate obj_conv;
28268         obj_conv.inner = (void*)(obj & (~1));
28269         obj_conv.is_owned = false;
28270         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28271         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
28272         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28273         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28274         CVec_u8Z_free(ret_var);
28275         return ret_arr;
28276 }
28277
28278 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
28279         LDKu8slice ser_ref;
28280         ser_ref.datalen = *((uint32_t*)ser);
28281         ser_ref.data = (int8_t*)(ser + 4);
28282         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
28283         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
28284         return (uint64_t)ret_conv;
28285 }
28286
28287 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
28288         LDKChannelUpdate obj_conv;
28289         obj_conv.inner = (void*)(obj & (~1));
28290         obj_conv.is_owned = false;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28292         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
28293         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28294         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28295         CVec_u8Z_free(ret_var);
28296         return ret_arr;
28297 }
28298
28299 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
28300         LDKu8slice ser_ref;
28301         ser_ref.datalen = *((uint32_t*)ser);
28302         ser_ref.data = (int8_t*)(ser + 4);
28303         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
28304         *ret_conv = ChannelUpdate_read(ser_ref);
28305         return (uint64_t)ret_conv;
28306 }
28307
28308 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
28309         LDKErrorMessage obj_conv;
28310         obj_conv.inner = (void*)(obj & (~1));
28311         obj_conv.is_owned = false;
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28313         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
28314         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28315         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28316         CVec_u8Z_free(ret_var);
28317         return ret_arr;
28318 }
28319
28320 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
28321         LDKu8slice ser_ref;
28322         ser_ref.datalen = *((uint32_t*)ser);
28323         ser_ref.data = (int8_t*)(ser + 4);
28324         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
28325         *ret_conv = ErrorMessage_read(ser_ref);
28326         return (uint64_t)ret_conv;
28327 }
28328
28329 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
28330         LDKUnsignedNodeAnnouncement obj_conv;
28331         obj_conv.inner = (void*)(obj & (~1));
28332         obj_conv.is_owned = false;
28333         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28334         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
28335         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28336         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28337         CVec_u8Z_free(ret_var);
28338         return ret_arr;
28339 }
28340
28341 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
28342         LDKu8slice ser_ref;
28343         ser_ref.datalen = *((uint32_t*)ser);
28344         ser_ref.data = (int8_t*)(ser + 4);
28345         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
28346         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
28347         return (uint64_t)ret_conv;
28348 }
28349
28350 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
28351         LDKNodeAnnouncement obj_conv;
28352         obj_conv.inner = (void*)(obj & (~1));
28353         obj_conv.is_owned = false;
28354         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28355         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
28356         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28357         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28358         CVec_u8Z_free(ret_var);
28359         return ret_arr;
28360 }
28361
28362 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
28363         LDKu8slice ser_ref;
28364         ser_ref.datalen = *((uint32_t*)ser);
28365         ser_ref.data = (int8_t*)(ser + 4);
28366         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
28367         *ret_conv = NodeAnnouncement_read(ser_ref);
28368         return (uint64_t)ret_conv;
28369 }
28370
28371 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
28372         LDKu8slice ser_ref;
28373         ser_ref.datalen = *((uint32_t*)ser);
28374         ser_ref.data = (int8_t*)(ser + 4);
28375         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
28376         *ret_conv = QueryShortChannelIds_read(ser_ref);
28377         return (uint64_t)ret_conv;
28378 }
28379
28380 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
28381         LDKQueryShortChannelIds obj_conv;
28382         obj_conv.inner = (void*)(obj & (~1));
28383         obj_conv.is_owned = false;
28384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28385         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
28386         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28387         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28388         CVec_u8Z_free(ret_var);
28389         return ret_arr;
28390 }
28391
28392 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
28393         LDKReplyShortChannelIdsEnd obj_conv;
28394         obj_conv.inner = (void*)(obj & (~1));
28395         obj_conv.is_owned = false;
28396         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28397         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
28398         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28399         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28400         CVec_u8Z_free(ret_var);
28401         return ret_arr;
28402 }
28403
28404 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
28405         LDKu8slice ser_ref;
28406         ser_ref.datalen = *((uint32_t*)ser);
28407         ser_ref.data = (int8_t*)(ser + 4);
28408         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
28409         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
28410         return (uint64_t)ret_conv;
28411 }
28412
28413 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
28414         LDKQueryChannelRange this_arg_conv;
28415         this_arg_conv.inner = (void*)(this_arg & (~1));
28416         this_arg_conv.is_owned = false;
28417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28418         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
28419         return ret_val;
28420 }
28421
28422 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
28423         LDKQueryChannelRange obj_conv;
28424         obj_conv.inner = (void*)(obj & (~1));
28425         obj_conv.is_owned = false;
28426         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28427         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
28428         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28429         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28430         CVec_u8Z_free(ret_var);
28431         return ret_arr;
28432 }
28433
28434 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
28435         LDKu8slice ser_ref;
28436         ser_ref.datalen = *((uint32_t*)ser);
28437         ser_ref.data = (int8_t*)(ser + 4);
28438         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
28439         *ret_conv = QueryChannelRange_read(ser_ref);
28440         return (uint64_t)ret_conv;
28441 }
28442
28443 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
28444         LDKu8slice ser_ref;
28445         ser_ref.datalen = *((uint32_t*)ser);
28446         ser_ref.data = (int8_t*)(ser + 4);
28447         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
28448         *ret_conv = ReplyChannelRange_read(ser_ref);
28449         return (uint64_t)ret_conv;
28450 }
28451
28452 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
28453         LDKReplyChannelRange obj_conv;
28454         obj_conv.inner = (void*)(obj & (~1));
28455         obj_conv.is_owned = false;
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28457         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
28458         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28459         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28460         CVec_u8Z_free(ret_var);
28461         return ret_arr;
28462 }
28463
28464 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
28465         LDKGossipTimestampFilter obj_conv;
28466         obj_conv.inner = (void*)(obj & (~1));
28467         obj_conv.is_owned = false;
28468         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28469         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
28470         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28471         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28472         CVec_u8Z_free(ret_var);
28473         return ret_arr;
28474 }
28475
28476 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
28477         LDKu8slice ser_ref;
28478         ser_ref.datalen = *((uint32_t*)ser);
28479         ser_ref.data = (int8_t*)(ser + 4);
28480         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
28481         *ret_conv = GossipTimestampFilter_read(ser_ref);
28482         return (uint64_t)ret_conv;
28483 }
28484
28485 void  __attribute__((visibility("default"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
28486         if ((this_ptr & 1) != 0) return;
28487         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28488         CHECK_ACCESS(this_ptr_ptr);
28489         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
28490         FREE((void*)this_ptr);
28491         CustomMessageHandler_free(this_ptr_conv);
28492 }
28493
28494 void  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
28495         LDKIgnoringMessageHandler this_obj_conv;
28496         this_obj_conv.inner = (void*)(this_obj & (~1));
28497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28499         IgnoringMessageHandler_free(this_obj_conv);
28500 }
28501
28502 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_new() {
28503         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
28504         uint64_t ret_ref = 0;
28505         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28506         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28508         ret_ref = (uint64_t)ret_var.inner;
28509         if (ret_var.is_owned) {
28510                 ret_ref |= 1;
28511         }
28512         return ret_ref;
28513 }
28514
28515 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28516         LDKIgnoringMessageHandler this_arg_conv;
28517         this_arg_conv.inner = (void*)(this_arg & (~1));
28518         this_arg_conv.is_owned = false;
28519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28520         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28521         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28522         return (uint64_t)ret_ret;
28523 }
28524
28525 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
28526         LDKIgnoringMessageHandler this_arg_conv;
28527         this_arg_conv.inner = (void*)(this_arg & (~1));
28528         this_arg_conv.is_owned = false;
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28530         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
28531         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
28532         return (uint64_t)ret_ret;
28533 }
28534
28535 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
28536         LDKIgnoringMessageHandler this_arg_conv;
28537         this_arg_conv.inner = (void*)(this_arg & (~1));
28538         this_arg_conv.is_owned = false;
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28540         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
28541         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
28542         return (uint64_t)ret_ret;
28543 }
28544
28545 uint32_t  __attribute__((visibility("default"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
28546         LDKIgnoringMessageHandler this_arg_conv;
28547         this_arg_conv.inner = (void*)(this_arg & (~1));
28548         this_arg_conv.is_owned = false;
28549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28550         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
28551         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
28552         return (uint64_t)ret_ret;
28553 }
28554
28555 void  __attribute__((visibility("default"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
28556         LDKErroringMessageHandler this_obj_conv;
28557         this_obj_conv.inner = (void*)(this_obj & (~1));
28558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28560         ErroringMessageHandler_free(this_obj_conv);
28561 }
28562
28563 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_new() {
28564         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
28565         uint64_t ret_ref = 0;
28566         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28567         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28569         ret_ref = (uint64_t)ret_var.inner;
28570         if (ret_var.is_owned) {
28571                 ret_ref |= 1;
28572         }
28573         return ret_ref;
28574 }
28575
28576 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28577         LDKErroringMessageHandler this_arg_conv;
28578         this_arg_conv.inner = (void*)(this_arg & (~1));
28579         this_arg_conv.is_owned = false;
28580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28581         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28582         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28583         return (uint64_t)ret_ret;
28584 }
28585
28586 uint32_t  __attribute__((visibility("default"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
28587         LDKErroringMessageHandler this_arg_conv;
28588         this_arg_conv.inner = (void*)(this_arg & (~1));
28589         this_arg_conv.is_owned = false;
28590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28591         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
28592         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
28593         return (uint64_t)ret_ret;
28594 }
28595
28596 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_obj) {
28597         LDKMessageHandler this_obj_conv;
28598         this_obj_conv.inner = (void*)(this_obj & (~1));
28599         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28601         MessageHandler_free(this_obj_conv);
28602 }
28603
28604 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
28605         LDKMessageHandler this_ptr_conv;
28606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28607         this_ptr_conv.is_owned = false;
28608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28609         // WARNING: This object doesn't live past this scope, needs clone!
28610         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
28611         return ret_ret;
28612 }
28613
28614 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
28615         LDKMessageHandler this_ptr_conv;
28616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28617         this_ptr_conv.is_owned = false;
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28619         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28620         CHECK_ACCESS(val_ptr);
28621         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
28622         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
28623 }
28624
28625 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
28626         LDKMessageHandler this_ptr_conv;
28627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28628         this_ptr_conv.is_owned = false;
28629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28630         // WARNING: This object doesn't live past this scope, needs clone!
28631         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
28632         return ret_ret;
28633 }
28634
28635 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
28636         LDKMessageHandler this_ptr_conv;
28637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28638         this_ptr_conv.is_owned = false;
28639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28640         void* val_ptr = (void*)(((uint64_t)val) & ~1);
28641         CHECK_ACCESS(val_ptr);
28642         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
28643         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
28644 }
28645
28646 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
28647         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
28648         CHECK_ACCESS(chan_handler_arg_ptr);
28649         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
28650         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
28651         CHECK_ACCESS(route_handler_arg_ptr);
28652         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
28653         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
28654         uint64_t ret_ref = 0;
28655         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28656         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28658         ret_ref = (uint64_t)ret_var.inner;
28659         if (ret_var.is_owned) {
28660                 ret_ref |= 1;
28661         }
28662         return ret_ref;
28663 }
28664
28665 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
28666         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28667         *ret_ret = SocketDescriptor_clone(arg);
28668         return (uint64_t)ret_ret;
28669 }
28670 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
28671         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
28672         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28673         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
28674         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
28675         return ret_val;
28676 }
28677
28678 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
28679         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
28680         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28681         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
28682         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28683         *ret_ret = SocketDescriptor_clone(orig_conv);
28684         return (uint64_t)ret_ret;
28685 }
28686
28687 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
28688         if ((this_ptr & 1) != 0) return;
28689         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28690         CHECK_ACCESS(this_ptr_ptr);
28691         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
28692         FREE((void*)this_ptr);
28693         SocketDescriptor_free(this_ptr_conv);
28694 }
28695
28696 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_obj) {
28697         LDKPeerHandleError this_obj_conv;
28698         this_obj_conv.inner = (void*)(this_obj & (~1));
28699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28701         PeerHandleError_free(this_obj_conv);
28702 }
28703
28704 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
28705         LDKPeerHandleError this_ptr_conv;
28706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28707         this_ptr_conv.is_owned = false;
28708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28709         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
28710         return ret_val;
28711 }
28712
28713 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
28714         LDKPeerHandleError this_ptr_conv;
28715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28716         this_ptr_conv.is_owned = false;
28717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28718         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
28719 }
28720
28721 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
28722         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
28723         uint64_t ret_ref = 0;
28724         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28725         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28727         ret_ref = (uint64_t)ret_var.inner;
28728         if (ret_var.is_owned) {
28729                 ret_ref |= 1;
28730         }
28731         return ret_ref;
28732 }
28733
28734 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
28735         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
28736 uint64_t ret_ref = 0;
28737 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28738 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28739 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28740 ret_ref = (uint64_t)ret_var.inner;
28741 if (ret_var.is_owned) {
28742         ret_ref |= 1;
28743 }
28744         return ret_ref;
28745 }
28746 int64_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
28747         LDKPeerHandleError arg_conv;
28748         arg_conv.inner = (void*)(arg & (~1));
28749         arg_conv.is_owned = false;
28750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28751         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
28752         return ret_val;
28753 }
28754
28755 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
28756         LDKPeerHandleError orig_conv;
28757         orig_conv.inner = (void*)(orig & (~1));
28758         orig_conv.is_owned = false;
28759         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28760         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
28761         uint64_t ret_ref = 0;
28762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28765         ret_ref = (uint64_t)ret_var.inner;
28766         if (ret_var.is_owned) {
28767                 ret_ref |= 1;
28768         }
28769         return ret_ref;
28770 }
28771
28772 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_obj) {
28773         LDKPeerManager this_obj_conv;
28774         this_obj_conv.inner = (void*)(this_obj & (~1));
28775         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28777         PeerManager_free(this_obj_conv);
28778 }
28779
28780 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger, uint32_t custom_message_handler) {
28781         LDKMessageHandler message_handler_conv;
28782         message_handler_conv.inner = (void*)(message_handler & (~1));
28783         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
28784         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
28785         // Warning: we need a move here but no clone is available for LDKMessageHandler
28786         LDKSecretKey our_node_secret_ref;
28787         CHECK(*((uint32_t*)our_node_secret) == 32);
28788         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
28789         unsigned char ephemeral_random_data_arr[32];
28790         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
28791         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
28792         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
28793         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
28794         CHECK_ACCESS(logger_ptr);
28795         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28796         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
28797         CHECK_ACCESS(custom_message_handler_ptr);
28798         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
28799         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
28800         uint64_t ret_ref = 0;
28801         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28802         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28803         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28804         ret_ref = (uint64_t)ret_var.inner;
28805         if (ret_var.is_owned) {
28806                 ret_ref |= 1;
28807         }
28808         return ret_ref;
28809 }
28810
28811 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
28812         LDKPeerManager this_arg_conv;
28813         this_arg_conv.inner = (void*)(this_arg & (~1));
28814         this_arg_conv.is_owned = false;
28815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28816         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
28817         ptrArray ret_arr = NULL;
28818         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
28819         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
28820         for (size_t m = 0; m < ret_var.datalen; m++) {
28821                 int8_tArray ret_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
28822                 memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
28823                 ret_arr_ptr[m] = ret_conv_12_arr;
28824         }
28825         
28826         FREE(ret_var.data);
28827         return ret_arr;
28828 }
28829
28830 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
28831         LDKPeerManager this_arg_conv;
28832         this_arg_conv.inner = (void*)(this_arg & (~1));
28833         this_arg_conv.is_owned = false;
28834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28835         LDKPublicKey their_node_id_ref;
28836         CHECK(*((uint32_t*)their_node_id) == 33);
28837         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
28838         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28839         CHECK_ACCESS(descriptor_ptr);
28840         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28841         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
28842         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
28843         return (uint64_t)ret_conv;
28844 }
28845
28846 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
28847         LDKPeerManager this_arg_conv;
28848         this_arg_conv.inner = (void*)(this_arg & (~1));
28849         this_arg_conv.is_owned = false;
28850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28851         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28852         CHECK_ACCESS(descriptor_ptr);
28853         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28854         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28855         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
28856         return (uint64_t)ret_conv;
28857 }
28858
28859 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
28860         LDKPeerManager this_arg_conv;
28861         this_arg_conv.inner = (void*)(this_arg & (~1));
28862         this_arg_conv.is_owned = false;
28863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28864         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28865         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28866         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28867         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28868         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
28869         return (uint64_t)ret_conv;
28870 }
28871
28872 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
28873         LDKPeerManager this_arg_conv;
28874         this_arg_conv.inner = (void*)(this_arg & (~1));
28875         this_arg_conv.is_owned = false;
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28877         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
28878         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
28879         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
28880         LDKu8slice data_ref;
28881         data_ref.datalen = *((uint32_t*)data);
28882         data_ref.data = (int8_t*)(data + 4);
28883         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
28884         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
28885         return (uint64_t)ret_conv;
28886 }
28887
28888 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
28889         LDKPeerManager this_arg_conv;
28890         this_arg_conv.inner = (void*)(this_arg & (~1));
28891         this_arg_conv.is_owned = false;
28892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28893         PeerManager_process_events(&this_arg_conv);
28894 }
28895
28896 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
28897         LDKPeerManager this_arg_conv;
28898         this_arg_conv.inner = (void*)(this_arg & (~1));
28899         this_arg_conv.is_owned = false;
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28901         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
28902         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28903         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28904         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
28905 }
28906
28907 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
28908         LDKPeerManager this_arg_conv;
28909         this_arg_conv.inner = (void*)(this_arg & (~1));
28910         this_arg_conv.is_owned = false;
28911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28912         LDKPublicKey node_id_ref;
28913         CHECK(*((uint32_t*)node_id) == 33);
28914         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
28915         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
28916 }
28917
28918 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
28919         LDKPeerManager this_arg_conv;
28920         this_arg_conv.inner = (void*)(this_arg & (~1));
28921         this_arg_conv.is_owned = false;
28922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28923         PeerManager_disconnect_all_peers(&this_arg_conv);
28924 }
28925
28926 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
28927         LDKPeerManager this_arg_conv;
28928         this_arg_conv.inner = (void*)(this_arg & (~1));
28929         this_arg_conv.is_owned = false;
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28931         PeerManager_timer_tick_occurred(&this_arg_conv);
28932 }
28933
28934 int64_t  __attribute__((visibility("default"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
28935         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
28936         return ret_val;
28937 }
28938
28939 int64_t  __attribute__((visibility("default"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
28940         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
28941         return ret_val;
28942 }
28943
28944 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
28945         unsigned char commitment_seed_arr[32];
28946         CHECK(*((uint32_t*)commitment_seed) == 32);
28947         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
28948         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
28949         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
28950         memcpy((uint8_t*)(ret_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
28951         return ret_arr;
28952 }
28953
28954 int8_tArray  __attribute__((visibility("default"))) TS_build_closing_transaction(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) {
28955         LDKCVec_u8Z to_holder_script_ref;
28956         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
28957         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
28958         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
28959         LDKCVec_u8Z to_counterparty_script_ref;
28960         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
28961         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
28962         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
28963         LDKOutPoint funding_outpoint_conv;
28964         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28965         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28966         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
28967         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28968         LDKTransaction ret_var = build_closing_transaction(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
28969         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
28970         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
28971         Transaction_free(ret_var);
28972         return ret_arr;
28973 }
28974
28975 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
28976         LDKPublicKey per_commitment_point_ref;
28977         CHECK(*((uint32_t*)per_commitment_point) == 33);
28978         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28979         unsigned char base_secret_arr[32];
28980         CHECK(*((uint32_t*)base_secret) == 32);
28981         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
28982         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
28983         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28984         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
28985         return (uint64_t)ret_conv;
28986 }
28987
28988 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
28989         LDKPublicKey per_commitment_point_ref;
28990         CHECK(*((uint32_t*)per_commitment_point) == 33);
28991         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
28992         LDKPublicKey base_point_ref;
28993         CHECK(*((uint32_t*)base_point) == 33);
28994         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
28995         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28996         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
28997         return (uint64_t)ret_conv;
28998 }
28999
29000 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
29001         unsigned char per_commitment_secret_arr[32];
29002         CHECK(*((uint32_t*)per_commitment_secret) == 32);
29003         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
29004         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
29005         unsigned char countersignatory_revocation_base_secret_arr[32];
29006         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
29007         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
29008         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
29009         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
29010         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
29011         return (uint64_t)ret_conv;
29012 }
29013
29014 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
29015         LDKPublicKey per_commitment_point_ref;
29016         CHECK(*((uint32_t*)per_commitment_point) == 33);
29017         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
29018         LDKPublicKey countersignatory_revocation_base_point_ref;
29019         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
29020         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
29021         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
29022         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
29023         return (uint64_t)ret_conv;
29024 }
29025
29026 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_obj) {
29027         LDKTxCreationKeys this_obj_conv;
29028         this_obj_conv.inner = (void*)(this_obj & (~1));
29029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29031         TxCreationKeys_free(this_obj_conv);
29032 }
29033
29034 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
29035         LDKTxCreationKeys this_ptr_conv;
29036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29037         this_ptr_conv.is_owned = false;
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29039         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29040         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29041         return ret_arr;
29042 }
29043
29044 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
29045         LDKTxCreationKeys this_ptr_conv;
29046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29047         this_ptr_conv.is_owned = false;
29048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29049         LDKPublicKey val_ref;
29050         CHECK(*((uint32_t*)val) == 33);
29051         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29052         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
29053 }
29054
29055 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
29056         LDKTxCreationKeys this_ptr_conv;
29057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29058         this_ptr_conv.is_owned = false;
29059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29060         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29061         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
29062         return ret_arr;
29063 }
29064
29065 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
29066         LDKTxCreationKeys this_ptr_conv;
29067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29068         this_ptr_conv.is_owned = false;
29069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29070         LDKPublicKey val_ref;
29071         CHECK(*((uint32_t*)val) == 33);
29072         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29073         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
29074 }
29075
29076 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
29077         LDKTxCreationKeys this_ptr_conv;
29078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29079         this_ptr_conv.is_owned = false;
29080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29081         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29082         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
29083         return ret_arr;
29084 }
29085
29086 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
29087         LDKTxCreationKeys this_ptr_conv;
29088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29089         this_ptr_conv.is_owned = false;
29090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29091         LDKPublicKey val_ref;
29092         CHECK(*((uint32_t*)val) == 33);
29093         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29094         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
29095 }
29096
29097 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
29098         LDKTxCreationKeys this_ptr_conv;
29099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29100         this_ptr_conv.is_owned = false;
29101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29102         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29103         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
29104         return ret_arr;
29105 }
29106
29107 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
29108         LDKTxCreationKeys this_ptr_conv;
29109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29110         this_ptr_conv.is_owned = false;
29111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29112         LDKPublicKey val_ref;
29113         CHECK(*((uint32_t*)val) == 33);
29114         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29115         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
29116 }
29117
29118 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
29119         LDKTxCreationKeys this_ptr_conv;
29120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29121         this_ptr_conv.is_owned = false;
29122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29123         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29124         memcpy((uint8_t*)(ret_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
29125         return ret_arr;
29126 }
29127
29128 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
29129         LDKTxCreationKeys this_ptr_conv;
29130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29131         this_ptr_conv.is_owned = false;
29132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29133         LDKPublicKey val_ref;
29134         CHECK(*((uint32_t*)val) == 33);
29135         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29136         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
29137 }
29138
29139 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_new(int8_tArray per_commitment_point_arg, int8_tArray revocation_key_arg, int8_tArray broadcaster_htlc_key_arg, int8_tArray countersignatory_htlc_key_arg, int8_tArray broadcaster_delayed_payment_key_arg) {
29140         LDKPublicKey per_commitment_point_arg_ref;
29141         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
29142         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
29143         LDKPublicKey revocation_key_arg_ref;
29144         CHECK(*((uint32_t*)revocation_key_arg) == 33);
29145         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
29146         LDKPublicKey broadcaster_htlc_key_arg_ref;
29147         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
29148         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
29149         LDKPublicKey countersignatory_htlc_key_arg_ref;
29150         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
29151         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
29152         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
29153         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
29154         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
29155         LDKTxCreationKeys ret_var = TxCreationKeys_new(per_commitment_point_arg_ref, revocation_key_arg_ref, broadcaster_htlc_key_arg_ref, countersignatory_htlc_key_arg_ref, broadcaster_delayed_payment_key_arg_ref);
29156         uint64_t ret_ref = 0;
29157         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29158         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29160         ret_ref = (uint64_t)ret_var.inner;
29161         if (ret_var.is_owned) {
29162                 ret_ref |= 1;
29163         }
29164         return ret_ref;
29165 }
29166
29167 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
29168         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
29169 uint64_t ret_ref = 0;
29170 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29171 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29172 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29173 ret_ref = (uint64_t)ret_var.inner;
29174 if (ret_var.is_owned) {
29175         ret_ref |= 1;
29176 }
29177         return ret_ref;
29178 }
29179 int64_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
29180         LDKTxCreationKeys arg_conv;
29181         arg_conv.inner = (void*)(arg & (~1));
29182         arg_conv.is_owned = false;
29183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29184         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
29185         return ret_val;
29186 }
29187
29188 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
29189         LDKTxCreationKeys orig_conv;
29190         orig_conv.inner = (void*)(orig & (~1));
29191         orig_conv.is_owned = false;
29192         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29193         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
29194         uint64_t ret_ref = 0;
29195         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29196         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29198         ret_ref = (uint64_t)ret_var.inner;
29199         if (ret_var.is_owned) {
29200                 ret_ref |= 1;
29201         }
29202         return ret_ref;
29203 }
29204
29205 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
29206         LDKTxCreationKeys obj_conv;
29207         obj_conv.inner = (void*)(obj & (~1));
29208         obj_conv.is_owned = false;
29209         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29210         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
29211         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29212         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29213         CVec_u8Z_free(ret_var);
29214         return ret_arr;
29215 }
29216
29217 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
29218         LDKu8slice ser_ref;
29219         ser_ref.datalen = *((uint32_t*)ser);
29220         ser_ref.data = (int8_t*)(ser + 4);
29221         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
29222         *ret_conv = TxCreationKeys_read(ser_ref);
29223         return (uint64_t)ret_conv;
29224 }
29225
29226 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
29227         LDKChannelPublicKeys this_obj_conv;
29228         this_obj_conv.inner = (void*)(this_obj & (~1));
29229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29231         ChannelPublicKeys_free(this_obj_conv);
29232 }
29233
29234 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
29235         LDKChannelPublicKeys this_ptr_conv;
29236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29237         this_ptr_conv.is_owned = false;
29238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29239         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29240         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29241         return ret_arr;
29242 }
29243
29244 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29245         LDKChannelPublicKeys this_ptr_conv;
29246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29247         this_ptr_conv.is_owned = false;
29248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29249         LDKPublicKey val_ref;
29250         CHECK(*((uint32_t*)val) == 33);
29251         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29252         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
29253 }
29254
29255 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
29256         LDKChannelPublicKeys this_ptr_conv;
29257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29258         this_ptr_conv.is_owned = false;
29259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29260         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29261         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29262         return ret_arr;
29263 }
29264
29265 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29266         LDKChannelPublicKeys this_ptr_conv;
29267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29268         this_ptr_conv.is_owned = false;
29269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29270         LDKPublicKey val_ref;
29271         CHECK(*((uint32_t*)val) == 33);
29272         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29273         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
29274 }
29275
29276 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
29277         LDKChannelPublicKeys this_ptr_conv;
29278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29279         this_ptr_conv.is_owned = false;
29280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29281         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29282         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
29283         return ret_arr;
29284 }
29285
29286 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29287         LDKChannelPublicKeys this_ptr_conv;
29288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29289         this_ptr_conv.is_owned = false;
29290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29291         LDKPublicKey val_ref;
29292         CHECK(*((uint32_t*)val) == 33);
29293         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29294         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
29295 }
29296
29297 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
29298         LDKChannelPublicKeys this_ptr_conv;
29299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29300         this_ptr_conv.is_owned = false;
29301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29302         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29303         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29304         return ret_arr;
29305 }
29306
29307 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29308         LDKChannelPublicKeys this_ptr_conv;
29309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29310         this_ptr_conv.is_owned = false;
29311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29312         LDKPublicKey val_ref;
29313         CHECK(*((uint32_t*)val) == 33);
29314         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29315         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29316 }
29317
29318 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
29319         LDKChannelPublicKeys this_ptr_conv;
29320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29321         this_ptr_conv.is_owned = false;
29322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29323         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
29324         memcpy((uint8_t*)(ret_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29325         return ret_arr;
29326 }
29327
29328 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29329         LDKChannelPublicKeys this_ptr_conv;
29330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29331         this_ptr_conv.is_owned = false;
29332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29333         LDKPublicKey val_ref;
29334         CHECK(*((uint32_t*)val) == 33);
29335         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
29336         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
29337 }
29338
29339 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_new(int8_tArray funding_pubkey_arg, int8_tArray revocation_basepoint_arg, int8_tArray payment_point_arg, int8_tArray delayed_payment_basepoint_arg, int8_tArray htlc_basepoint_arg) {
29340         LDKPublicKey funding_pubkey_arg_ref;
29341         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
29342         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
29343         LDKPublicKey revocation_basepoint_arg_ref;
29344         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
29345         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
29346         LDKPublicKey payment_point_arg_ref;
29347         CHECK(*((uint32_t*)payment_point_arg) == 33);
29348         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
29349         LDKPublicKey delayed_payment_basepoint_arg_ref;
29350         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
29351         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
29352         LDKPublicKey htlc_basepoint_arg_ref;
29353         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
29354         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
29355         LDKChannelPublicKeys ret_var = ChannelPublicKeys_new(funding_pubkey_arg_ref, revocation_basepoint_arg_ref, payment_point_arg_ref, delayed_payment_basepoint_arg_ref, htlc_basepoint_arg_ref);
29356         uint64_t ret_ref = 0;
29357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29360         ret_ref = (uint64_t)ret_var.inner;
29361         if (ret_var.is_owned) {
29362                 ret_ref |= 1;
29363         }
29364         return ret_ref;
29365 }
29366
29367 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
29368         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
29369 uint64_t ret_ref = 0;
29370 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29371 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29372 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29373 ret_ref = (uint64_t)ret_var.inner;
29374 if (ret_var.is_owned) {
29375         ret_ref |= 1;
29376 }
29377         return ret_ref;
29378 }
29379 int64_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
29380         LDKChannelPublicKeys arg_conv;
29381         arg_conv.inner = (void*)(arg & (~1));
29382         arg_conv.is_owned = false;
29383         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29384         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
29385         return ret_val;
29386 }
29387
29388 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
29389         LDKChannelPublicKeys orig_conv;
29390         orig_conv.inner = (void*)(orig & (~1));
29391         orig_conv.is_owned = false;
29392         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29393         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
29394         uint64_t ret_ref = 0;
29395         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29396         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29398         ret_ref = (uint64_t)ret_var.inner;
29399         if (ret_var.is_owned) {
29400                 ret_ref |= 1;
29401         }
29402         return ret_ref;
29403 }
29404
29405 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
29406         LDKChannelPublicKeys obj_conv;
29407         obj_conv.inner = (void*)(obj & (~1));
29408         obj_conv.is_owned = false;
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29410         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
29411         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29412         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29413         CVec_u8Z_free(ret_var);
29414         return ret_arr;
29415 }
29416
29417 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
29418         LDKu8slice ser_ref;
29419         ser_ref.datalen = *((uint32_t*)ser);
29420         ser_ref.data = (int8_t*)(ser + 4);
29421         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
29422         *ret_conv = ChannelPublicKeys_read(ser_ref);
29423         return (uint64_t)ret_conv;
29424 }
29425
29426 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_derive_new(int8_tArray per_commitment_point, int8_tArray broadcaster_delayed_payment_base, int8_tArray broadcaster_htlc_base, int8_tArray countersignatory_revocation_base, int8_tArray countersignatory_htlc_base) {
29427         LDKPublicKey per_commitment_point_ref;
29428         CHECK(*((uint32_t*)per_commitment_point) == 33);
29429         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
29430         LDKPublicKey broadcaster_delayed_payment_base_ref;
29431         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
29432         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
29433         LDKPublicKey broadcaster_htlc_base_ref;
29434         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
29435         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
29436         LDKPublicKey countersignatory_revocation_base_ref;
29437         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
29438         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
29439         LDKPublicKey countersignatory_htlc_base_ref;
29440         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
29441         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
29442         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29443         *ret_conv = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
29444         return (uint64_t)ret_conv;
29445 }
29446
29447 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
29448         LDKPublicKey per_commitment_point_ref;
29449         CHECK(*((uint32_t*)per_commitment_point) == 33);
29450         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
29451         LDKChannelPublicKeys broadcaster_keys_conv;
29452         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
29453         broadcaster_keys_conv.is_owned = false;
29454         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
29455         LDKChannelPublicKeys countersignatory_keys_conv;
29456         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
29457         countersignatory_keys_conv.is_owned = false;
29458         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
29459         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29460         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
29461         return (uint64_t)ret_conv;
29462 }
29463
29464 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
29465         LDKPublicKey revocation_key_ref;
29466         CHECK(*((uint32_t*)revocation_key) == 33);
29467         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
29468         LDKPublicKey broadcaster_delayed_payment_key_ref;
29469         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
29470         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
29471         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
29472         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29473         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29474         CVec_u8Z_free(ret_var);
29475         return ret_arr;
29476 }
29477
29478 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
29479         LDKHTLCOutputInCommitment this_obj_conv;
29480         this_obj_conv.inner = (void*)(this_obj & (~1));
29481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29483         HTLCOutputInCommitment_free(this_obj_conv);
29484 }
29485
29486 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
29487         LDKHTLCOutputInCommitment this_ptr_conv;
29488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29489         this_ptr_conv.is_owned = false;
29490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29491         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
29492         return ret_val;
29493 }
29494
29495 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
29496         LDKHTLCOutputInCommitment this_ptr_conv;
29497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29498         this_ptr_conv.is_owned = false;
29499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29500         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
29501 }
29502
29503 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
29504         LDKHTLCOutputInCommitment this_ptr_conv;
29505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29506         this_ptr_conv.is_owned = false;
29507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29508         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
29509         return ret_val;
29510 }
29511
29512 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
29513         LDKHTLCOutputInCommitment this_ptr_conv;
29514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29515         this_ptr_conv.is_owned = false;
29516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29517         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
29518 }
29519
29520 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
29521         LDKHTLCOutputInCommitment this_ptr_conv;
29522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29523         this_ptr_conv.is_owned = false;
29524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29525         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
29526         return ret_val;
29527 }
29528
29529 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29530         LDKHTLCOutputInCommitment this_ptr_conv;
29531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29532         this_ptr_conv.is_owned = false;
29533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29534         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
29535 }
29536
29537 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
29538         LDKHTLCOutputInCommitment this_ptr_conv;
29539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29540         this_ptr_conv.is_owned = false;
29541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29542         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
29543         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
29544         return ret_arr;
29545 }
29546
29547 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29548         LDKHTLCOutputInCommitment this_ptr_conv;
29549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29550         this_ptr_conv.is_owned = false;
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29552         LDKThirtyTwoBytes val_ref;
29553         CHECK(*((uint32_t*)val) == 32);
29554         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
29555         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
29556 }
29557
29558 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
29559         LDKHTLCOutputInCommitment this_ptr_conv;
29560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29561         this_ptr_conv.is_owned = false;
29562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29563         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29564         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
29565         uint64_t ret_ref = (uint64_t)ret_copy;
29566         return ret_ref;
29567 }
29568
29569 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
29570         LDKHTLCOutputInCommitment this_ptr_conv;
29571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29572         this_ptr_conv.is_owned = false;
29573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29574         void* val_ptr = (void*)(((uint64_t)val) & ~1);
29575         CHECK_ACCESS(val_ptr);
29576         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29577         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
29578         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
29579 }
29580
29581 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_new(jboolean offered_arg, int64_t amount_msat_arg, int32_t cltv_expiry_arg, int8_tArray payment_hash_arg, uint32_t transaction_output_index_arg) {
29582         LDKThirtyTwoBytes payment_hash_arg_ref;
29583         CHECK(*((uint32_t*)payment_hash_arg) == 32);
29584         memcpy(payment_hash_arg_ref.data, (uint8_t*)(payment_hash_arg + 4), 32);
29585         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
29586         CHECK_ACCESS(transaction_output_index_arg_ptr);
29587         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
29588         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
29589         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
29590         uint64_t ret_ref = 0;
29591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29594         ret_ref = (uint64_t)ret_var.inner;
29595         if (ret_var.is_owned) {
29596                 ret_ref |= 1;
29597         }
29598         return ret_ref;
29599 }
29600
29601 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
29602         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
29603 uint64_t ret_ref = 0;
29604 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29605 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29606 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29607 ret_ref = (uint64_t)ret_var.inner;
29608 if (ret_var.is_owned) {
29609         ret_ref |= 1;
29610 }
29611         return ret_ref;
29612 }
29613 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
29614         LDKHTLCOutputInCommitment arg_conv;
29615         arg_conv.inner = (void*)(arg & (~1));
29616         arg_conv.is_owned = false;
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29618         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
29619         return ret_val;
29620 }
29621
29622 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
29623         LDKHTLCOutputInCommitment orig_conv;
29624         orig_conv.inner = (void*)(orig & (~1));
29625         orig_conv.is_owned = false;
29626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29627         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
29628         uint64_t ret_ref = 0;
29629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29632         ret_ref = (uint64_t)ret_var.inner;
29633         if (ret_var.is_owned) {
29634                 ret_ref |= 1;
29635         }
29636         return ret_ref;
29637 }
29638
29639 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
29640         LDKHTLCOutputInCommitment obj_conv;
29641         obj_conv.inner = (void*)(obj & (~1));
29642         obj_conv.is_owned = false;
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29644         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
29645         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29646         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29647         CVec_u8Z_free(ret_var);
29648         return ret_arr;
29649 }
29650
29651 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
29652         LDKu8slice ser_ref;
29653         ser_ref.datalen = *((uint32_t*)ser);
29654         ser_ref.data = (int8_t*)(ser + 4);
29655         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
29656         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
29657         return (uint64_t)ret_conv;
29658 }
29659
29660 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
29661         LDKHTLCOutputInCommitment htlc_conv;
29662         htlc_conv.inner = (void*)(htlc & (~1));
29663         htlc_conv.is_owned = false;
29664         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29665         LDKTxCreationKeys keys_conv;
29666         keys_conv.inner = (void*)(keys & (~1));
29667         keys_conv.is_owned = false;
29668         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
29669         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
29670         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29671         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29672         CVec_u8Z_free(ret_var);
29673         return ret_arr;
29674 }
29675
29676 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
29677         LDKPublicKey broadcaster_ref;
29678         CHECK(*((uint32_t*)broadcaster) == 33);
29679         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
29680         LDKPublicKey countersignatory_ref;
29681         CHECK(*((uint32_t*)countersignatory) == 33);
29682         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
29683         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
29684         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29685         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29686         CVec_u8Z_free(ret_var);
29687         return ret_arr;
29688 }
29689
29690 int8_tArray  __attribute__((visibility("default"))) TS_build_htlc_transaction(int8_tArray commitment_txid, int32_t feerate_per_kw, int16_t contest_delay, uint32_t htlc, jboolean opt_anchors, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
29691         unsigned char commitment_txid_arr[32];
29692         CHECK(*((uint32_t*)commitment_txid) == 32);
29693         memcpy(commitment_txid_arr, (uint8_t*)(commitment_txid + 4), 32);
29694         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
29695         LDKHTLCOutputInCommitment htlc_conv;
29696         htlc_conv.inner = (void*)(htlc & (~1));
29697         htlc_conv.is_owned = false;
29698         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29699         LDKPublicKey broadcaster_delayed_payment_key_ref;
29700         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
29701         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
29702         LDKPublicKey revocation_key_ref;
29703         CHECK(*((uint32_t*)revocation_key) == 33);
29704         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
29705         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, opt_anchors, broadcaster_delayed_payment_key_ref, revocation_key_ref);
29706         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29707         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29708         Transaction_free(ret_var);
29709         return ret_arr;
29710 }
29711
29712 int8_tArray  __attribute__((visibility("default"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
29713         LDKPublicKey funding_pubkey_ref;
29714         CHECK(*((uint32_t*)funding_pubkey) == 33);
29715         memcpy(funding_pubkey_ref.compressed_form, (uint8_t*)(funding_pubkey + 4), 33);
29716         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
29717         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
29718         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
29719         CVec_u8Z_free(ret_var);
29720         return ret_arr;
29721 }
29722
29723 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
29724         LDKChannelTransactionParameters this_obj_conv;
29725         this_obj_conv.inner = (void*)(this_obj & (~1));
29726         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29728         ChannelTransactionParameters_free(this_obj_conv);
29729 }
29730
29731 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
29732         LDKChannelTransactionParameters this_ptr_conv;
29733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29734         this_ptr_conv.is_owned = false;
29735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29736         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
29737         uint64_t ret_ref = 0;
29738         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29739         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29741         ret_ref = (uint64_t)ret_var.inner;
29742         if (ret_var.is_owned) {
29743                 ret_ref |= 1;
29744         }
29745         return ret_ref;
29746 }
29747
29748 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
29749         LDKChannelTransactionParameters this_ptr_conv;
29750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29751         this_ptr_conv.is_owned = false;
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29753         LDKChannelPublicKeys val_conv;
29754         val_conv.inner = (void*)(val & (~1));
29755         val_conv.is_owned = (val & 1) || (val == 0);
29756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29757         val_conv = ChannelPublicKeys_clone(&val_conv);
29758         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
29759 }
29760
29761 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
29762         LDKChannelTransactionParameters this_ptr_conv;
29763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29764         this_ptr_conv.is_owned = false;
29765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29766         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
29767         return ret_val;
29768 }
29769
29770 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29771         LDKChannelTransactionParameters this_ptr_conv;
29772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29773         this_ptr_conv.is_owned = false;
29774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29775         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
29776 }
29777
29778 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
29779         LDKChannelTransactionParameters this_ptr_conv;
29780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29781         this_ptr_conv.is_owned = false;
29782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29783         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
29784         return ret_val;
29785 }
29786
29787 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
29788         LDKChannelTransactionParameters this_ptr_conv;
29789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29790         this_ptr_conv.is_owned = false;
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29792         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
29793 }
29794
29795 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
29796         LDKChannelTransactionParameters this_ptr_conv;
29797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29798         this_ptr_conv.is_owned = false;
29799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29800         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
29801         uint64_t ret_ref = 0;
29802         if ((uint64_t)ret_var.inner > 4096) {
29803                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29804                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29806                 ret_ref = (uint64_t)ret_var.inner;
29807                 if (ret_var.is_owned) {
29808                         ret_ref |= 1;
29809                 }
29810         }
29811         return ret_ref;
29812 }
29813
29814 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
29815         LDKChannelTransactionParameters this_ptr_conv;
29816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29817         this_ptr_conv.is_owned = false;
29818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29819         LDKCounterpartyChannelTransactionParameters val_conv;
29820         val_conv.inner = (void*)(val & (~1));
29821         val_conv.is_owned = (val & 1) || (val == 0);
29822         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29823         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
29824         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
29825 }
29826
29827 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
29828         LDKChannelTransactionParameters this_ptr_conv;
29829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29830         this_ptr_conv.is_owned = false;
29831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29832         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
29833         uint64_t ret_ref = 0;
29834         if ((uint64_t)ret_var.inner > 4096) {
29835                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29836                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29838                 ret_ref = (uint64_t)ret_var.inner;
29839                 if (ret_var.is_owned) {
29840                         ret_ref |= 1;
29841                 }
29842         }
29843         return ret_ref;
29844 }
29845
29846 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
29847         LDKChannelTransactionParameters this_ptr_conv;
29848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29849         this_ptr_conv.is_owned = false;
29850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29851         LDKOutPoint val_conv;
29852         val_conv.inner = (void*)(val & (~1));
29853         val_conv.is_owned = (val & 1) || (val == 0);
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29855         val_conv = OutPoint_clone(&val_conv);
29856         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
29857 }
29858
29859 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
29860         LDKChannelTransactionParameters this_ptr_conv;
29861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29862         this_ptr_conv.is_owned = false;
29863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29864         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
29865         return ret_conv;
29866 }
29867
29868 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
29869         LDKChannelTransactionParameters this_ptr_conv;
29870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29871         this_ptr_conv.is_owned = false;
29872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29873         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
29874         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
29875 }
29876
29877 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_new(uint32_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, uint32_t counterparty_parameters_arg, uint32_t funding_outpoint_arg, uint32_t opt_anchors_arg) {
29878         LDKChannelPublicKeys holder_pubkeys_arg_conv;
29879         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
29880         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
29882         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
29883         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
29884         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
29885         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
29886         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
29887         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
29888         LDKOutPoint funding_outpoint_arg_conv;
29889         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
29890         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
29891         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
29892         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
29893         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
29894         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_new(holder_pubkeys_arg_conv, holder_selected_contest_delay_arg, is_outbound_from_holder_arg, counterparty_parameters_arg_conv, funding_outpoint_arg_conv, opt_anchors_arg_conv);
29895         uint64_t ret_ref = 0;
29896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29899         ret_ref = (uint64_t)ret_var.inner;
29900         if (ret_var.is_owned) {
29901                 ret_ref |= 1;
29902         }
29903         return ret_ref;
29904 }
29905
29906 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
29907         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
29908 uint64_t ret_ref = 0;
29909 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29910 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29911 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29912 ret_ref = (uint64_t)ret_var.inner;
29913 if (ret_var.is_owned) {
29914         ret_ref |= 1;
29915 }
29916         return ret_ref;
29917 }
29918 int64_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
29919         LDKChannelTransactionParameters arg_conv;
29920         arg_conv.inner = (void*)(arg & (~1));
29921         arg_conv.is_owned = false;
29922         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29923         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
29924         return ret_val;
29925 }
29926
29927 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
29928         LDKChannelTransactionParameters orig_conv;
29929         orig_conv.inner = (void*)(orig & (~1));
29930         orig_conv.is_owned = false;
29931         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29932         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
29933         uint64_t ret_ref = 0;
29934         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29935         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29937         ret_ref = (uint64_t)ret_var.inner;
29938         if (ret_var.is_owned) {
29939                 ret_ref |= 1;
29940         }
29941         return ret_ref;
29942 }
29943
29944 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
29945         LDKCounterpartyChannelTransactionParameters this_obj_conv;
29946         this_obj_conv.inner = (void*)(this_obj & (~1));
29947         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29949         CounterpartyChannelTransactionParameters_free(this_obj_conv);
29950 }
29951
29952 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
29953         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29955         this_ptr_conv.is_owned = false;
29956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29957         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
29958         uint64_t ret_ref = 0;
29959         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29960         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29962         ret_ref = (uint64_t)ret_var.inner;
29963         if (ret_var.is_owned) {
29964                 ret_ref |= 1;
29965         }
29966         return ret_ref;
29967 }
29968
29969 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
29970         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29972         this_ptr_conv.is_owned = false;
29973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29974         LDKChannelPublicKeys val_conv;
29975         val_conv.inner = (void*)(val & (~1));
29976         val_conv.is_owned = (val & 1) || (val == 0);
29977         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29978         val_conv = ChannelPublicKeys_clone(&val_conv);
29979         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
29980 }
29981
29982 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
29983         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29985         this_ptr_conv.is_owned = false;
29986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29987         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
29988         return ret_val;
29989 }
29990
29991 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29992         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29994         this_ptr_conv.is_owned = false;
29995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29996         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
29997 }
29998
29999 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
30000         LDKChannelPublicKeys pubkeys_arg_conv;
30001         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
30002         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
30003         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
30004         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
30005         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
30006         uint64_t ret_ref = 0;
30007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30010         ret_ref = (uint64_t)ret_var.inner;
30011         if (ret_var.is_owned) {
30012                 ret_ref |= 1;
30013         }
30014         return ret_ref;
30015 }
30016
30017 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
30018         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
30019 uint64_t ret_ref = 0;
30020 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30021 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30023 ret_ref = (uint64_t)ret_var.inner;
30024 if (ret_var.is_owned) {
30025         ret_ref |= 1;
30026 }
30027         return ret_ref;
30028 }
30029 int64_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
30030         LDKCounterpartyChannelTransactionParameters arg_conv;
30031         arg_conv.inner = (void*)(arg & (~1));
30032         arg_conv.is_owned = false;
30033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30034         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
30035         return ret_val;
30036 }
30037
30038 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
30039         LDKCounterpartyChannelTransactionParameters orig_conv;
30040         orig_conv.inner = (void*)(orig & (~1));
30041         orig_conv.is_owned = false;
30042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30043         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
30044         uint64_t ret_ref = 0;
30045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30048         ret_ref = (uint64_t)ret_var.inner;
30049         if (ret_var.is_owned) {
30050                 ret_ref |= 1;
30051         }
30052         return ret_ref;
30053 }
30054
30055 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
30056         LDKChannelTransactionParameters this_arg_conv;
30057         this_arg_conv.inner = (void*)(this_arg & (~1));
30058         this_arg_conv.is_owned = false;
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30060         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
30061         return ret_val;
30062 }
30063
30064 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
30065         LDKChannelTransactionParameters this_arg_conv;
30066         this_arg_conv.inner = (void*)(this_arg & (~1));
30067         this_arg_conv.is_owned = false;
30068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30069         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
30070         uint64_t ret_ref = 0;
30071         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30072         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30074         ret_ref = (uint64_t)ret_var.inner;
30075         if (ret_var.is_owned) {
30076                 ret_ref |= 1;
30077         }
30078         return ret_ref;
30079 }
30080
30081 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
30082         LDKChannelTransactionParameters this_arg_conv;
30083         this_arg_conv.inner = (void*)(this_arg & (~1));
30084         this_arg_conv.is_owned = false;
30085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30086         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
30087         uint64_t ret_ref = 0;
30088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30091         ret_ref = (uint64_t)ret_var.inner;
30092         if (ret_var.is_owned) {
30093                 ret_ref |= 1;
30094         }
30095         return ret_ref;
30096 }
30097
30098 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
30099         LDKCounterpartyChannelTransactionParameters obj_conv;
30100         obj_conv.inner = (void*)(obj & (~1));
30101         obj_conv.is_owned = false;
30102         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30103         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
30104         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30105         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30106         CVec_u8Z_free(ret_var);
30107         return ret_arr;
30108 }
30109
30110 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
30111         LDKu8slice ser_ref;
30112         ser_ref.datalen = *((uint32_t*)ser);
30113         ser_ref.data = (int8_t*)(ser + 4);
30114         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
30115         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
30116         return (uint64_t)ret_conv;
30117 }
30118
30119 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
30120         LDKChannelTransactionParameters obj_conv;
30121         obj_conv.inner = (void*)(obj & (~1));
30122         obj_conv.is_owned = false;
30123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30124         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
30125         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30126         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30127         CVec_u8Z_free(ret_var);
30128         return ret_arr;
30129 }
30130
30131 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
30132         LDKu8slice ser_ref;
30133         ser_ref.datalen = *((uint32_t*)ser);
30134         ser_ref.data = (int8_t*)(ser + 4);
30135         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
30136         *ret_conv = ChannelTransactionParameters_read(ser_ref);
30137         return (uint64_t)ret_conv;
30138 }
30139
30140 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
30141         LDKDirectedChannelTransactionParameters this_obj_conv;
30142         this_obj_conv.inner = (void*)(this_obj & (~1));
30143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30145         DirectedChannelTransactionParameters_free(this_obj_conv);
30146 }
30147
30148 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
30149         LDKDirectedChannelTransactionParameters this_arg_conv;
30150         this_arg_conv.inner = (void*)(this_arg & (~1));
30151         this_arg_conv.is_owned = false;
30152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30153         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
30154         uint64_t ret_ref = 0;
30155         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30156         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30158         ret_ref = (uint64_t)ret_var.inner;
30159         if (ret_var.is_owned) {
30160                 ret_ref |= 1;
30161         }
30162         return ret_ref;
30163 }
30164
30165 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
30166         LDKDirectedChannelTransactionParameters this_arg_conv;
30167         this_arg_conv.inner = (void*)(this_arg & (~1));
30168         this_arg_conv.is_owned = false;
30169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30170         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
30171         uint64_t ret_ref = 0;
30172         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30173         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30175         ret_ref = (uint64_t)ret_var.inner;
30176         if (ret_var.is_owned) {
30177                 ret_ref |= 1;
30178         }
30179         return ret_ref;
30180 }
30181
30182 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
30183         LDKDirectedChannelTransactionParameters this_arg_conv;
30184         this_arg_conv.inner = (void*)(this_arg & (~1));
30185         this_arg_conv.is_owned = false;
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30187         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
30188         return ret_val;
30189 }
30190
30191 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
30192         LDKDirectedChannelTransactionParameters this_arg_conv;
30193         this_arg_conv.inner = (void*)(this_arg & (~1));
30194         this_arg_conv.is_owned = false;
30195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30196         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
30197         return ret_val;
30198 }
30199
30200 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
30201         LDKDirectedChannelTransactionParameters this_arg_conv;
30202         this_arg_conv.inner = (void*)(this_arg & (~1));
30203         this_arg_conv.is_owned = false;
30204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30205         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
30206         uint64_t ret_ref = 0;
30207         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30208         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30210         ret_ref = (uint64_t)ret_var.inner;
30211         if (ret_var.is_owned) {
30212                 ret_ref |= 1;
30213         }
30214         return ret_ref;
30215 }
30216
30217 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
30218         LDKDirectedChannelTransactionParameters this_arg_conv;
30219         this_arg_conv.inner = (void*)(this_arg & (~1));
30220         this_arg_conv.is_owned = false;
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30222         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
30223         return ret_val;
30224 }
30225
30226 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
30227         LDKHolderCommitmentTransaction this_obj_conv;
30228         this_obj_conv.inner = (void*)(this_obj & (~1));
30229         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30231         HolderCommitmentTransaction_free(this_obj_conv);
30232 }
30233
30234 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
30235         LDKHolderCommitmentTransaction this_ptr_conv;
30236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30237         this_ptr_conv.is_owned = false;
30238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30239         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
30240         memcpy((uint8_t*)(ret_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
30241         return ret_arr;
30242 }
30243
30244 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
30245         LDKHolderCommitmentTransaction this_ptr_conv;
30246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30247         this_ptr_conv.is_owned = false;
30248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30249         LDKSignature val_ref;
30250         CHECK(*((uint32_t*)val) == 64);
30251         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
30252         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
30253 }
30254
30255 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
30256         LDKHolderCommitmentTransaction this_ptr_conv;
30257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30258         this_ptr_conv.is_owned = false;
30259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30260         LDKCVec_SignatureZ val_constr;
30261         val_constr.datalen = *((uint32_t*)val);
30262         if (val_constr.datalen > 0)
30263                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30264         else
30265                 val_constr.data = NULL;
30266         int8_tArray* val_vals = (int8_tArray*)(val + 4);
30267         for (size_t m = 0; m < val_constr.datalen; m++) {
30268                 int8_tArray val_conv_12 = val_vals[m];
30269                 LDKSignature val_conv_12_ref;
30270                 CHECK(*((uint32_t*)val_conv_12) == 64);
30271                 memcpy(val_conv_12_ref.compact_form, (uint8_t*)(val_conv_12 + 4), 64);
30272                 val_constr.data[m] = val_conv_12_ref;
30273         }
30274         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
30275 }
30276
30277 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
30278         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
30279 uint64_t ret_ref = 0;
30280 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30281 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30282 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30283 ret_ref = (uint64_t)ret_var.inner;
30284 if (ret_var.is_owned) {
30285         ret_ref |= 1;
30286 }
30287         return ret_ref;
30288 }
30289 int64_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
30290         LDKHolderCommitmentTransaction arg_conv;
30291         arg_conv.inner = (void*)(arg & (~1));
30292         arg_conv.is_owned = false;
30293         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30294         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
30295         return ret_val;
30296 }
30297
30298 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
30299         LDKHolderCommitmentTransaction orig_conv;
30300         orig_conv.inner = (void*)(orig & (~1));
30301         orig_conv.is_owned = false;
30302         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30303         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
30304         uint64_t ret_ref = 0;
30305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30308         ret_ref = (uint64_t)ret_var.inner;
30309         if (ret_var.is_owned) {
30310                 ret_ref |= 1;
30311         }
30312         return ret_ref;
30313 }
30314
30315 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
30316         LDKHolderCommitmentTransaction obj_conv;
30317         obj_conv.inner = (void*)(obj & (~1));
30318         obj_conv.is_owned = false;
30319         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30320         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
30321         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30322         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30323         CVec_u8Z_free(ret_var);
30324         return ret_arr;
30325 }
30326
30327 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
30328         LDKu8slice ser_ref;
30329         ser_ref.datalen = *((uint32_t*)ser);
30330         ser_ref.data = (int8_t*)(ser + 4);
30331         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
30332         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
30333         return (uint64_t)ret_conv;
30334 }
30335
30336 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_new(uint32_t commitment_tx, int8_tArray counterparty_sig, ptrArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
30337         LDKCommitmentTransaction commitment_tx_conv;
30338         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
30339         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
30340         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
30341         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
30342         LDKSignature counterparty_sig_ref;
30343         CHECK(*((uint32_t*)counterparty_sig) == 64);
30344         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
30345         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
30346         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
30347         if (counterparty_htlc_sigs_constr.datalen > 0)
30348                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30349         else
30350                 counterparty_htlc_sigs_constr.data = NULL;
30351         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
30352         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
30353                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
30354                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
30355                 CHECK(*((uint32_t*)counterparty_htlc_sigs_conv_12) == 64);
30356                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, (uint8_t*)(counterparty_htlc_sigs_conv_12 + 4), 64);
30357                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
30358         }
30359         LDKPublicKey holder_funding_key_ref;
30360         CHECK(*((uint32_t*)holder_funding_key) == 33);
30361         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
30362         LDKPublicKey counterparty_funding_key_ref;
30363         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
30364         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
30365         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
30366         uint64_t ret_ref = 0;
30367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30370         ret_ref = (uint64_t)ret_var.inner;
30371         if (ret_var.is_owned) {
30372                 ret_ref |= 1;
30373         }
30374         return ret_ref;
30375 }
30376
30377 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
30378         LDKBuiltCommitmentTransaction this_obj_conv;
30379         this_obj_conv.inner = (void*)(this_obj & (~1));
30380         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30382         BuiltCommitmentTransaction_free(this_obj_conv);
30383 }
30384
30385 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
30386         LDKBuiltCommitmentTransaction this_ptr_conv;
30387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30388         this_ptr_conv.is_owned = false;
30389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30390         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
30391         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30392         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30393         Transaction_free(ret_var);
30394         return ret_arr;
30395 }
30396
30397 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
30398         LDKBuiltCommitmentTransaction this_ptr_conv;
30399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30400         this_ptr_conv.is_owned = false;
30401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30402         LDKTransaction val_ref;
30403         val_ref.datalen = *((uint32_t*)val);
30404         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
30405         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
30406         val_ref.data_is_owned = true;
30407         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
30408 }
30409
30410 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
30411         LDKBuiltCommitmentTransaction this_ptr_conv;
30412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30413         this_ptr_conv.is_owned = false;
30414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30415         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
30416         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
30417         return ret_arr;
30418 }
30419
30420 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
30421         LDKBuiltCommitmentTransaction this_ptr_conv;
30422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30423         this_ptr_conv.is_owned = false;
30424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30425         LDKThirtyTwoBytes val_ref;
30426         CHECK(*((uint32_t*)val) == 32);
30427         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
30428         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
30429 }
30430
30431 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
30432         LDKTransaction transaction_arg_ref;
30433         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
30434         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
30435         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
30436         transaction_arg_ref.data_is_owned = true;
30437         LDKThirtyTwoBytes txid_arg_ref;
30438         CHECK(*((uint32_t*)txid_arg) == 32);
30439         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
30440         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
30441         uint64_t ret_ref = 0;
30442         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30443         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30445         ret_ref = (uint64_t)ret_var.inner;
30446         if (ret_var.is_owned) {
30447                 ret_ref |= 1;
30448         }
30449         return ret_ref;
30450 }
30451
30452 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
30453         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
30454 uint64_t ret_ref = 0;
30455 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30456 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30458 ret_ref = (uint64_t)ret_var.inner;
30459 if (ret_var.is_owned) {
30460         ret_ref |= 1;
30461 }
30462         return ret_ref;
30463 }
30464 int64_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
30465         LDKBuiltCommitmentTransaction arg_conv;
30466         arg_conv.inner = (void*)(arg & (~1));
30467         arg_conv.is_owned = false;
30468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30469         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
30470         return ret_val;
30471 }
30472
30473 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
30474         LDKBuiltCommitmentTransaction orig_conv;
30475         orig_conv.inner = (void*)(orig & (~1));
30476         orig_conv.is_owned = false;
30477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30478         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
30479         uint64_t ret_ref = 0;
30480         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30481         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30483         ret_ref = (uint64_t)ret_var.inner;
30484         if (ret_var.is_owned) {
30485                 ret_ref |= 1;
30486         }
30487         return ret_ref;
30488 }
30489
30490 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
30491         LDKBuiltCommitmentTransaction obj_conv;
30492         obj_conv.inner = (void*)(obj & (~1));
30493         obj_conv.is_owned = false;
30494         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30495         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
30496         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30497         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30498         CVec_u8Z_free(ret_var);
30499         return ret_arr;
30500 }
30501
30502 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
30503         LDKu8slice ser_ref;
30504         ser_ref.datalen = *((uint32_t*)ser);
30505         ser_ref.data = (int8_t*)(ser + 4);
30506         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
30507         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
30508         return (uint64_t)ret_conv;
30509 }
30510
30511 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
30512         LDKBuiltCommitmentTransaction this_arg_conv;
30513         this_arg_conv.inner = (void*)(this_arg & (~1));
30514         this_arg_conv.is_owned = false;
30515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30516         LDKu8slice funding_redeemscript_ref;
30517         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
30518         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
30519         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
30520         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30521         return ret_arr;
30522 }
30523
30524 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
30525         LDKBuiltCommitmentTransaction this_arg_conv;
30526         this_arg_conv.inner = (void*)(this_arg & (~1));
30527         this_arg_conv.is_owned = false;
30528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30529         unsigned char funding_key_arr[32];
30530         CHECK(*((uint32_t*)funding_key) == 32);
30531         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
30532         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30533         LDKu8slice funding_redeemscript_ref;
30534         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
30535         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
30536         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
30537         memcpy((uint8_t*)(ret_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30538         return ret_arr;
30539 }
30540
30541 void  __attribute__((visibility("default"))) TS_ClosingTransaction_free(uint32_t this_obj) {
30542         LDKClosingTransaction this_obj_conv;
30543         this_obj_conv.inner = (void*)(this_obj & (~1));
30544         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30546         ClosingTransaction_free(this_obj_conv);
30547 }
30548
30549 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
30550         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
30551 uint64_t ret_ref = 0;
30552 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30553 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30554 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30555 ret_ref = (uint64_t)ret_var.inner;
30556 if (ret_var.is_owned) {
30557         ret_ref |= 1;
30558 }
30559         return ret_ref;
30560 }
30561 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
30562         LDKClosingTransaction arg_conv;
30563         arg_conv.inner = (void*)(arg & (~1));
30564         arg_conv.is_owned = false;
30565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30566         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
30567         return ret_val;
30568 }
30569
30570 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_clone(uint32_t orig) {
30571         LDKClosingTransaction orig_conv;
30572         orig_conv.inner = (void*)(orig & (~1));
30573         orig_conv.is_owned = false;
30574         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30575         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
30576         uint64_t ret_ref = 0;
30577         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30578         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30580         ret_ref = (uint64_t)ret_var.inner;
30581         if (ret_var.is_owned) {
30582                 ret_ref |= 1;
30583         }
30584         return ret_ref;
30585 }
30586
30587 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_hash(uint32_t o) {
30588         LDKClosingTransaction o_conv;
30589         o_conv.inner = (void*)(o & (~1));
30590         o_conv.is_owned = false;
30591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30592         int64_t ret_val = ClosingTransaction_hash(&o_conv);
30593         return ret_val;
30594 }
30595
30596 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_new(int64_t to_holder_value_sat, int64_t to_counterparty_value_sat, int8_tArray to_holder_script, int8_tArray to_counterparty_script, uint32_t funding_outpoint) {
30597         LDKCVec_u8Z to_holder_script_ref;
30598         to_holder_script_ref.datalen = *((uint32_t*)to_holder_script);
30599         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
30600         memcpy(to_holder_script_ref.data, (uint8_t*)(to_holder_script + 4), to_holder_script_ref.datalen);
30601         LDKCVec_u8Z to_counterparty_script_ref;
30602         to_counterparty_script_ref.datalen = *((uint32_t*)to_counterparty_script);
30603         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
30604         memcpy(to_counterparty_script_ref.data, (uint8_t*)(to_counterparty_script + 4), to_counterparty_script_ref.datalen);
30605         LDKOutPoint funding_outpoint_conv;
30606         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30607         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30608         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30609         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30610         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
30611         uint64_t ret_ref = 0;
30612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30615         ret_ref = (uint64_t)ret_var.inner;
30616         if (ret_var.is_owned) {
30617                 ret_ref |= 1;
30618         }
30619         return ret_ref;
30620 }
30621
30622 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
30623         LDKClosingTransaction this_arg_conv;
30624         this_arg_conv.inner = (void*)(this_arg & (~1));
30625         this_arg_conv.is_owned = false;
30626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30627         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
30628         uint64_t ret_ref = 0;
30629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30632         ret_ref = (uint64_t)ret_var.inner;
30633         if (ret_var.is_owned) {
30634                 ret_ref |= 1;
30635         }
30636         return ret_ref;
30637 }
30638
30639 uint32_t  __attribute__((visibility("default"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
30640         LDKClosingTransaction this_arg_conv;
30641         this_arg_conv.inner = (void*)(this_arg & (~1));
30642         this_arg_conv.is_owned = false;
30643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30644         LDKOutPoint funding_outpoint_conv;
30645         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30646         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30647         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30648         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30649         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
30650         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
30651         return (uint64_t)ret_conv;
30652 }
30653
30654 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
30655         LDKClosingTransaction this_arg_conv;
30656         this_arg_conv.inner = (void*)(this_arg & (~1));
30657         this_arg_conv.is_owned = false;
30658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30659         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
30660         return ret_val;
30661 }
30662
30663 int64_t  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
30664         LDKClosingTransaction this_arg_conv;
30665         this_arg_conv.inner = (void*)(this_arg & (~1));
30666         this_arg_conv.is_owned = false;
30667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30668         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
30669         return ret_val;
30670 }
30671
30672 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
30673         LDKClosingTransaction this_arg_conv;
30674         this_arg_conv.inner = (void*)(this_arg & (~1));
30675         this_arg_conv.is_owned = false;
30676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30677         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
30678         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30679         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30680         return ret_arr;
30681 }
30682
30683 int8_tArray  __attribute__((visibility("default"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
30684         LDKClosingTransaction this_arg_conv;
30685         this_arg_conv.inner = (void*)(this_arg & (~1));
30686         this_arg_conv.is_owned = false;
30687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30688         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
30689         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30690         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30691         return ret_arr;
30692 }
30693
30694 void  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
30695         LDKTrustedClosingTransaction this_obj_conv;
30696         this_obj_conv.inner = (void*)(this_obj & (~1));
30697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30699         TrustedClosingTransaction_free(this_obj_conv);
30700 }
30701
30702 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
30703         LDKTrustedClosingTransaction this_arg_conv;
30704         this_arg_conv.inner = (void*)(this_arg & (~1));
30705         this_arg_conv.is_owned = false;
30706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30707         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
30708         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30709         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30710         Transaction_free(ret_var);
30711         return ret_arr;
30712 }
30713
30714 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
30715         LDKTrustedClosingTransaction this_arg_conv;
30716         this_arg_conv.inner = (void*)(this_arg & (~1));
30717         this_arg_conv.is_owned = false;
30718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30719         LDKu8slice funding_redeemscript_ref;
30720         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
30721         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
30722         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
30723         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30724         return ret_arr;
30725 }
30726
30727 int8_tArray  __attribute__((visibility("default"))) TS_TrustedClosingTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
30728         LDKTrustedClosingTransaction this_arg_conv;
30729         this_arg_conv.inner = (void*)(this_arg & (~1));
30730         this_arg_conv.is_owned = false;
30731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30732         unsigned char funding_key_arr[32];
30733         CHECK(*((uint32_t*)funding_key) == 32);
30734         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
30735         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30736         LDKu8slice funding_redeemscript_ref;
30737         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
30738         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
30739         int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
30740         memcpy((uint8_t*)(ret_arr + 4), TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30741         return ret_arr;
30742 }
30743
30744 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
30745         LDKCommitmentTransaction this_obj_conv;
30746         this_obj_conv.inner = (void*)(this_obj & (~1));
30747         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30749         CommitmentTransaction_free(this_obj_conv);
30750 }
30751
30752 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
30753         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
30754 uint64_t ret_ref = 0;
30755 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30756 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30757 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30758 ret_ref = (uint64_t)ret_var.inner;
30759 if (ret_var.is_owned) {
30760         ret_ref |= 1;
30761 }
30762         return ret_ref;
30763 }
30764 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
30765         LDKCommitmentTransaction arg_conv;
30766         arg_conv.inner = (void*)(arg & (~1));
30767         arg_conv.is_owned = false;
30768         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30769         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
30770         return ret_val;
30771 }
30772
30773 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
30774         LDKCommitmentTransaction orig_conv;
30775         orig_conv.inner = (void*)(orig & (~1));
30776         orig_conv.is_owned = false;
30777         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30778         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
30779         uint64_t ret_ref = 0;
30780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30783         ret_ref = (uint64_t)ret_var.inner;
30784         if (ret_var.is_owned) {
30785                 ret_ref |= 1;
30786         }
30787         return ret_ref;
30788 }
30789
30790 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
30791         LDKCommitmentTransaction obj_conv;
30792         obj_conv.inner = (void*)(obj & (~1));
30793         obj_conv.is_owned = false;
30794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30795         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
30796         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
30797         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
30798         CVec_u8Z_free(ret_var);
30799         return ret_arr;
30800 }
30801
30802 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
30803         LDKu8slice ser_ref;
30804         ser_ref.datalen = *((uint32_t*)ser);
30805         ser_ref.data = (int8_t*)(ser + 4);
30806         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
30807         *ret_conv = CommitmentTransaction_read(ser_ref);
30808         return (uint64_t)ret_conv;
30809 }
30810
30811 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
30812         LDKCommitmentTransaction this_arg_conv;
30813         this_arg_conv.inner = (void*)(this_arg & (~1));
30814         this_arg_conv.is_owned = false;
30815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30816         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
30817         return ret_val;
30818 }
30819
30820 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
30821         LDKCommitmentTransaction this_arg_conv;
30822         this_arg_conv.inner = (void*)(this_arg & (~1));
30823         this_arg_conv.is_owned = false;
30824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30825         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
30826         return ret_val;
30827 }
30828
30829 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
30830         LDKCommitmentTransaction this_arg_conv;
30831         this_arg_conv.inner = (void*)(this_arg & (~1));
30832         this_arg_conv.is_owned = false;
30833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30834         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
30835         return ret_val;
30836 }
30837
30838 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
30839         LDKCommitmentTransaction this_arg_conv;
30840         this_arg_conv.inner = (void*)(this_arg & (~1));
30841         this_arg_conv.is_owned = false;
30842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30843         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
30844         return ret_val;
30845 }
30846
30847 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
30848         LDKCommitmentTransaction this_arg_conv;
30849         this_arg_conv.inner = (void*)(this_arg & (~1));
30850         this_arg_conv.is_owned = false;
30851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30852         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
30853         uint64_t ret_ref = 0;
30854         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30855         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30857         ret_ref = (uint64_t)ret_var.inner;
30858         if (ret_var.is_owned) {
30859                 ret_ref |= 1;
30860         }
30861         return ret_ref;
30862 }
30863
30864 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
30865         LDKCommitmentTransaction this_arg_conv;
30866         this_arg_conv.inner = (void*)(this_arg & (~1));
30867         this_arg_conv.is_owned = false;
30868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30869         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30870         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30871         channel_parameters_conv.is_owned = false;
30872         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30873         LDKChannelPublicKeys broadcaster_keys_conv;
30874         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
30875         broadcaster_keys_conv.is_owned = false;
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
30877         LDKChannelPublicKeys countersignatory_keys_conv;
30878         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
30879         countersignatory_keys_conv.is_owned = false;
30880         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
30881         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
30882         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
30883         return (uint64_t)ret_conv;
30884 }
30885
30886 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
30887         LDKTrustedCommitmentTransaction this_obj_conv;
30888         this_obj_conv.inner = (void*)(this_obj & (~1));
30889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30891         TrustedCommitmentTransaction_free(this_obj_conv);
30892 }
30893
30894 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
30895         LDKTrustedCommitmentTransaction this_arg_conv;
30896         this_arg_conv.inner = (void*)(this_arg & (~1));
30897         this_arg_conv.is_owned = false;
30898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30899         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
30900         memcpy((uint8_t*)(ret_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
30901         return ret_arr;
30902 }
30903
30904 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
30905         LDKTrustedCommitmentTransaction this_arg_conv;
30906         this_arg_conv.inner = (void*)(this_arg & (~1));
30907         this_arg_conv.is_owned = false;
30908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30909         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
30910         uint64_t ret_ref = 0;
30911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30914         ret_ref = (uint64_t)ret_var.inner;
30915         if (ret_var.is_owned) {
30916                 ret_ref |= 1;
30917         }
30918         return ret_ref;
30919 }
30920
30921 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
30922         LDKTrustedCommitmentTransaction this_arg_conv;
30923         this_arg_conv.inner = (void*)(this_arg & (~1));
30924         this_arg_conv.is_owned = false;
30925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30926         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
30927         uint64_t ret_ref = 0;
30928         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30929         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30931         ret_ref = (uint64_t)ret_var.inner;
30932         if (ret_var.is_owned) {
30933                 ret_ref |= 1;
30934         }
30935         return ret_ref;
30936 }
30937
30938 jboolean  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
30939         LDKTrustedCommitmentTransaction this_arg_conv;
30940         this_arg_conv.inner = (void*)(this_arg & (~1));
30941         this_arg_conv.is_owned = false;
30942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30943         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
30944         return ret_val;
30945 }
30946
30947 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
30948         LDKTrustedCommitmentTransaction this_arg_conv;
30949         this_arg_conv.inner = (void*)(this_arg & (~1));
30950         this_arg_conv.is_owned = false;
30951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30952         unsigned char htlc_base_key_arr[32];
30953         CHECK(*((uint32_t*)htlc_base_key) == 32);
30954         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
30955         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
30956         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30957         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30958         channel_parameters_conv.is_owned = false;
30959         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30960         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
30961         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
30962         return (uint64_t)ret_conv;
30963 }
30964
30965 int64_t  __attribute__((visibility("default"))) TS_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
30966         LDKPublicKey broadcaster_payment_basepoint_ref;
30967         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
30968         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
30969         LDKPublicKey countersignatory_payment_basepoint_ref;
30970         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
30971         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
30972         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
30973         return ret_val;
30974 }
30975
30976 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
30977         LDKInitFeatures a_conv;
30978         a_conv.inner = (void*)(a & (~1));
30979         a_conv.is_owned = false;
30980         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30981         LDKInitFeatures b_conv;
30982         b_conv.inner = (void*)(b & (~1));
30983         b_conv.is_owned = false;
30984         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30985         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
30986         return ret_val;
30987 }
30988
30989 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
30990         LDKNodeFeatures a_conv;
30991         a_conv.inner = (void*)(a & (~1));
30992         a_conv.is_owned = false;
30993         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30994         LDKNodeFeatures b_conv;
30995         b_conv.inner = (void*)(b & (~1));
30996         b_conv.is_owned = false;
30997         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30998         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
30999         return ret_val;
31000 }
31001
31002 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
31003         LDKChannelFeatures a_conv;
31004         a_conv.inner = (void*)(a & (~1));
31005         a_conv.is_owned = false;
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
31007         LDKChannelFeatures b_conv;
31008         b_conv.inner = (void*)(b & (~1));
31009         b_conv.is_owned = false;
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
31011         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
31012         return ret_val;
31013 }
31014
31015 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
31016         LDKInvoiceFeatures a_conv;
31017         a_conv.inner = (void*)(a & (~1));
31018         a_conv.is_owned = false;
31019         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
31020         LDKInvoiceFeatures b_conv;
31021         b_conv.inner = (void*)(b & (~1));
31022         b_conv.is_owned = false;
31023         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
31024         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
31025         return ret_val;
31026 }
31027
31028 jboolean  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
31029         LDKChannelTypeFeatures a_conv;
31030         a_conv.inner = (void*)(a & (~1));
31031         a_conv.is_owned = false;
31032         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
31033         LDKChannelTypeFeatures b_conv;
31034         b_conv.inner = (void*)(b & (~1));
31035         b_conv.is_owned = false;
31036         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
31037         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
31038         return ret_val;
31039 }
31040
31041 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
31042         LDKInitFeatures ret_var = InitFeatures_clone(arg);
31043 uint64_t ret_ref = 0;
31044 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31045 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31046 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31047 ret_ref = (uint64_t)ret_var.inner;
31048 if (ret_var.is_owned) {
31049         ret_ref |= 1;
31050 }
31051         return ret_ref;
31052 }
31053 int64_t  __attribute__((visibility("default"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
31054         LDKInitFeatures arg_conv;
31055         arg_conv.inner = (void*)(arg & (~1));
31056         arg_conv.is_owned = false;
31057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31058         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
31059         return ret_val;
31060 }
31061
31062 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_clone(uint32_t orig) {
31063         LDKInitFeatures orig_conv;
31064         orig_conv.inner = (void*)(orig & (~1));
31065         orig_conv.is_owned = false;
31066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31067         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
31068         uint64_t ret_ref = 0;
31069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31072         ret_ref = (uint64_t)ret_var.inner;
31073         if (ret_var.is_owned) {
31074                 ret_ref |= 1;
31075         }
31076         return ret_ref;
31077 }
31078
31079 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
31080         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
31081 uint64_t ret_ref = 0;
31082 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31083 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31085 ret_ref = (uint64_t)ret_var.inner;
31086 if (ret_var.is_owned) {
31087         ret_ref |= 1;
31088 }
31089         return ret_ref;
31090 }
31091 int64_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
31092         LDKNodeFeatures arg_conv;
31093         arg_conv.inner = (void*)(arg & (~1));
31094         arg_conv.is_owned = false;
31095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31096         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
31097         return ret_val;
31098 }
31099
31100 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_clone(uint32_t orig) {
31101         LDKNodeFeatures orig_conv;
31102         orig_conv.inner = (void*)(orig & (~1));
31103         orig_conv.is_owned = false;
31104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31105         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
31106         uint64_t ret_ref = 0;
31107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31110         ret_ref = (uint64_t)ret_var.inner;
31111         if (ret_var.is_owned) {
31112                 ret_ref |= 1;
31113         }
31114         return ret_ref;
31115 }
31116
31117 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
31118         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
31119 uint64_t ret_ref = 0;
31120 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31121 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31122 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31123 ret_ref = (uint64_t)ret_var.inner;
31124 if (ret_var.is_owned) {
31125         ret_ref |= 1;
31126 }
31127         return ret_ref;
31128 }
31129 int64_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
31130         LDKChannelFeatures arg_conv;
31131         arg_conv.inner = (void*)(arg & (~1));
31132         arg_conv.is_owned = false;
31133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31134         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
31135         return ret_val;
31136 }
31137
31138 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_clone(uint32_t orig) {
31139         LDKChannelFeatures orig_conv;
31140         orig_conv.inner = (void*)(orig & (~1));
31141         orig_conv.is_owned = false;
31142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31143         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
31144         uint64_t ret_ref = 0;
31145         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31146         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31148         ret_ref = (uint64_t)ret_var.inner;
31149         if (ret_var.is_owned) {
31150                 ret_ref |= 1;
31151         }
31152         return ret_ref;
31153 }
31154
31155 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
31156         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
31157 uint64_t ret_ref = 0;
31158 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31159 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31160 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31161 ret_ref = (uint64_t)ret_var.inner;
31162 if (ret_var.is_owned) {
31163         ret_ref |= 1;
31164 }
31165         return ret_ref;
31166 }
31167 int64_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
31168         LDKInvoiceFeatures arg_conv;
31169         arg_conv.inner = (void*)(arg & (~1));
31170         arg_conv.is_owned = false;
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31172         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
31173         return ret_val;
31174 }
31175
31176 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_clone(uint32_t orig) {
31177         LDKInvoiceFeatures orig_conv;
31178         orig_conv.inner = (void*)(orig & (~1));
31179         orig_conv.is_owned = false;
31180         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31181         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
31182         uint64_t ret_ref = 0;
31183         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31184         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31186         ret_ref = (uint64_t)ret_var.inner;
31187         if (ret_var.is_owned) {
31188                 ret_ref |= 1;
31189         }
31190         return ret_ref;
31191 }
31192
31193 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
31194         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
31195 uint64_t ret_ref = 0;
31196 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31197 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31198 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31199 ret_ref = (uint64_t)ret_var.inner;
31200 if (ret_var.is_owned) {
31201         ret_ref |= 1;
31202 }
31203         return ret_ref;
31204 }
31205 int64_t  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
31206         LDKChannelTypeFeatures arg_conv;
31207         arg_conv.inner = (void*)(arg & (~1));
31208         arg_conv.is_owned = false;
31209         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31210         int64_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
31211         return ret_val;
31212 }
31213
31214 uint32_t  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
31215         LDKChannelTypeFeatures orig_conv;
31216         orig_conv.inner = (void*)(orig & (~1));
31217         orig_conv.is_owned = false;
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31219         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
31220         uint64_t ret_ref = 0;
31221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31224         ret_ref = (uint64_t)ret_var.inner;
31225         if (ret_var.is_owned) {
31226                 ret_ref |= 1;
31227         }
31228         return ret_ref;
31229 }
31230
31231 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_obj) {
31232         LDKInitFeatures this_obj_conv;
31233         this_obj_conv.inner = (void*)(this_obj & (~1));
31234         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31236         InitFeatures_free(this_obj_conv);
31237 }
31238
31239 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_obj) {
31240         LDKNodeFeatures this_obj_conv;
31241         this_obj_conv.inner = (void*)(this_obj & (~1));
31242         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31244         NodeFeatures_free(this_obj_conv);
31245 }
31246
31247 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_obj) {
31248         LDKChannelFeatures this_obj_conv;
31249         this_obj_conv.inner = (void*)(this_obj & (~1));
31250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31252         ChannelFeatures_free(this_obj_conv);
31253 }
31254
31255 void  __attribute__((visibility("default"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
31256         LDKInvoiceFeatures this_obj_conv;
31257         this_obj_conv.inner = (void*)(this_obj & (~1));
31258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31260         InvoiceFeatures_free(this_obj_conv);
31261 }
31262
31263 void  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
31264         LDKChannelTypeFeatures this_obj_conv;
31265         this_obj_conv.inner = (void*)(this_obj & (~1));
31266         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31268         ChannelTypeFeatures_free(this_obj_conv);
31269 }
31270
31271 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_empty() {
31272         LDKInitFeatures ret_var = InitFeatures_empty();
31273         uint64_t ret_ref = 0;
31274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31277         ret_ref = (uint64_t)ret_var.inner;
31278         if (ret_var.is_owned) {
31279                 ret_ref |= 1;
31280         }
31281         return ret_ref;
31282 }
31283
31284 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_known() {
31285         LDKInitFeatures ret_var = InitFeatures_known();
31286         uint64_t ret_ref = 0;
31287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31290         ret_ref = (uint64_t)ret_var.inner;
31291         if (ret_var.is_owned) {
31292                 ret_ref |= 1;
31293         }
31294         return ret_ref;
31295 }
31296
31297 jboolean  __attribute__((visibility("default"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
31298         LDKInitFeatures this_arg_conv;
31299         this_arg_conv.inner = (void*)(this_arg & (~1));
31300         this_arg_conv.is_owned = false;
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31302         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
31303         return ret_val;
31304 }
31305
31306 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_empty() {
31307         LDKNodeFeatures ret_var = NodeFeatures_empty();
31308         uint64_t ret_ref = 0;
31309         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31310         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31311         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31312         ret_ref = (uint64_t)ret_var.inner;
31313         if (ret_var.is_owned) {
31314                 ret_ref |= 1;
31315         }
31316         return ret_ref;
31317 }
31318
31319 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_known() {
31320         LDKNodeFeatures ret_var = NodeFeatures_known();
31321         uint64_t ret_ref = 0;
31322         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31323         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31325         ret_ref = (uint64_t)ret_var.inner;
31326         if (ret_var.is_owned) {
31327                 ret_ref |= 1;
31328         }
31329         return ret_ref;
31330 }
31331
31332 jboolean  __attribute__((visibility("default"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
31333         LDKNodeFeatures this_arg_conv;
31334         this_arg_conv.inner = (void*)(this_arg & (~1));
31335         this_arg_conv.is_owned = false;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31337         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
31338         return ret_val;
31339 }
31340
31341 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_empty() {
31342         LDKChannelFeatures ret_var = ChannelFeatures_empty();
31343         uint64_t ret_ref = 0;
31344         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31345         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31347         ret_ref = (uint64_t)ret_var.inner;
31348         if (ret_var.is_owned) {
31349                 ret_ref |= 1;
31350         }
31351         return ret_ref;
31352 }
31353
31354 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_known() {
31355         LDKChannelFeatures ret_var = ChannelFeatures_known();
31356         uint64_t ret_ref = 0;
31357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31360         ret_ref = (uint64_t)ret_var.inner;
31361         if (ret_var.is_owned) {
31362                 ret_ref |= 1;
31363         }
31364         return ret_ref;
31365 }
31366
31367 jboolean  __attribute__((visibility("default"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
31368         LDKChannelFeatures this_arg_conv;
31369         this_arg_conv.inner = (void*)(this_arg & (~1));
31370         this_arg_conv.is_owned = false;
31371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31372         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
31373         return ret_val;
31374 }
31375
31376 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_empty() {
31377         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
31378         uint64_t ret_ref = 0;
31379         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31380         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31382         ret_ref = (uint64_t)ret_var.inner;
31383         if (ret_var.is_owned) {
31384                 ret_ref |= 1;
31385         }
31386         return ret_ref;
31387 }
31388
31389 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_known() {
31390         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
31391         uint64_t ret_ref = 0;
31392         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31393         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31395         ret_ref = (uint64_t)ret_var.inner;
31396         if (ret_var.is_owned) {
31397                 ret_ref |= 1;
31398         }
31399         return ret_ref;
31400 }
31401
31402 jboolean  __attribute__((visibility("default"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
31403         LDKInvoiceFeatures this_arg_conv;
31404         this_arg_conv.inner = (void*)(this_arg & (~1));
31405         this_arg_conv.is_owned = false;
31406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31407         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
31408         return ret_val;
31409 }
31410
31411 uint32_t  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_empty() {
31412         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
31413         uint64_t ret_ref = 0;
31414         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31415         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31417         ret_ref = (uint64_t)ret_var.inner;
31418         if (ret_var.is_owned) {
31419                 ret_ref |= 1;
31420         }
31421         return ret_ref;
31422 }
31423
31424 uint32_t  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_known() {
31425         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
31426         uint64_t ret_ref = 0;
31427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31430         ret_ref = (uint64_t)ret_var.inner;
31431         if (ret_var.is_owned) {
31432                 ret_ref |= 1;
31433         }
31434         return ret_ref;
31435 }
31436
31437 jboolean  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
31438         LDKChannelTypeFeatures this_arg_conv;
31439         this_arg_conv.inner = (void*)(this_arg & (~1));
31440         this_arg_conv.is_owned = false;
31441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31442         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
31443         return ret_val;
31444 }
31445
31446 int8_tArray  __attribute__((visibility("default"))) TS_InitFeatures_write(uint32_t obj) {
31447         LDKInitFeatures obj_conv;
31448         obj_conv.inner = (void*)(obj & (~1));
31449         obj_conv.is_owned = false;
31450         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31451         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
31452         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31453         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31454         CVec_u8Z_free(ret_var);
31455         return ret_arr;
31456 }
31457
31458 uint32_t  __attribute__((visibility("default"))) TS_InitFeatures_read(int8_tArray ser) {
31459         LDKu8slice ser_ref;
31460         ser_ref.datalen = *((uint32_t*)ser);
31461         ser_ref.data = (int8_t*)(ser + 4);
31462         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
31463         *ret_conv = InitFeatures_read(ser_ref);
31464         return (uint64_t)ret_conv;
31465 }
31466
31467 int8_tArray  __attribute__((visibility("default"))) TS_ChannelFeatures_write(uint32_t obj) {
31468         LDKChannelFeatures obj_conv;
31469         obj_conv.inner = (void*)(obj & (~1));
31470         obj_conv.is_owned = false;
31471         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31472         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
31473         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31474         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31475         CVec_u8Z_free(ret_var);
31476         return ret_arr;
31477 }
31478
31479 uint32_t  __attribute__((visibility("default"))) TS_ChannelFeatures_read(int8_tArray ser) {
31480         LDKu8slice ser_ref;
31481         ser_ref.datalen = *((uint32_t*)ser);
31482         ser_ref.data = (int8_t*)(ser + 4);
31483         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
31484         *ret_conv = ChannelFeatures_read(ser_ref);
31485         return (uint64_t)ret_conv;
31486 }
31487
31488 int8_tArray  __attribute__((visibility("default"))) TS_NodeFeatures_write(uint32_t obj) {
31489         LDKNodeFeatures obj_conv;
31490         obj_conv.inner = (void*)(obj & (~1));
31491         obj_conv.is_owned = false;
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31493         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
31494         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31495         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31496         CVec_u8Z_free(ret_var);
31497         return ret_arr;
31498 }
31499
31500 uint32_t  __attribute__((visibility("default"))) TS_NodeFeatures_read(int8_tArray ser) {
31501         LDKu8slice ser_ref;
31502         ser_ref.datalen = *((uint32_t*)ser);
31503         ser_ref.data = (int8_t*)(ser + 4);
31504         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
31505         *ret_conv = NodeFeatures_read(ser_ref);
31506         return (uint64_t)ret_conv;
31507 }
31508
31509 int8_tArray  __attribute__((visibility("default"))) TS_InvoiceFeatures_write(uint32_t obj) {
31510         LDKInvoiceFeatures obj_conv;
31511         obj_conv.inner = (void*)(obj & (~1));
31512         obj_conv.is_owned = false;
31513         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31514         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
31515         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31516         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31517         CVec_u8Z_free(ret_var);
31518         return ret_arr;
31519 }
31520
31521 uint32_t  __attribute__((visibility("default"))) TS_InvoiceFeatures_read(int8_tArray ser) {
31522         LDKu8slice ser_ref;
31523         ser_ref.datalen = *((uint32_t*)ser);
31524         ser_ref.data = (int8_t*)(ser + 4);
31525         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
31526         *ret_conv = InvoiceFeatures_read(ser_ref);
31527         return (uint64_t)ret_conv;
31528 }
31529
31530 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
31531         LDKChannelTypeFeatures obj_conv;
31532         obj_conv.inner = (void*)(obj & (~1));
31533         obj_conv.is_owned = false;
31534         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31535         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
31536         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31537         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31538         CVec_u8Z_free(ret_var);
31539         return ret_arr;
31540 }
31541
31542 uint32_t  __attribute__((visibility("default"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
31543         LDKu8slice ser_ref;
31544         ser_ref.datalen = *((uint32_t*)ser);
31545         ser_ref.data = (int8_t*)(ser + 4);
31546         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
31547         *ret_conv = ChannelTypeFeatures_read(ser_ref);
31548         return (uint64_t)ret_conv;
31549 }
31550
31551 void  __attribute__((visibility("default"))) TS_ShutdownScript_free(uint32_t this_obj) {
31552         LDKShutdownScript this_obj_conv;
31553         this_obj_conv.inner = (void*)(this_obj & (~1));
31554         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31556         ShutdownScript_free(this_obj_conv);
31557 }
31558
31559 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
31560         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
31561 uint64_t ret_ref = 0;
31562 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31563 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31564 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31565 ret_ref = (uint64_t)ret_var.inner;
31566 if (ret_var.is_owned) {
31567         ret_ref |= 1;
31568 }
31569         return ret_ref;
31570 }
31571 int64_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
31572         LDKShutdownScript arg_conv;
31573         arg_conv.inner = (void*)(arg & (~1));
31574         arg_conv.is_owned = false;
31575         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31576         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
31577         return ret_val;
31578 }
31579
31580 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_clone(uint32_t orig) {
31581         LDKShutdownScript orig_conv;
31582         orig_conv.inner = (void*)(orig & (~1));
31583         orig_conv.is_owned = false;
31584         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31585         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
31586         uint64_t ret_ref = 0;
31587         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31588         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31590         ret_ref = (uint64_t)ret_var.inner;
31591         if (ret_var.is_owned) {
31592                 ret_ref |= 1;
31593         }
31594         return ret_ref;
31595 }
31596
31597 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
31598         LDKInvalidShutdownScript this_obj_conv;
31599         this_obj_conv.inner = (void*)(this_obj & (~1));
31600         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31602         InvalidShutdownScript_free(this_obj_conv);
31603 }
31604
31605 int8_tArray  __attribute__((visibility("default"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
31606         LDKInvalidShutdownScript this_ptr_conv;
31607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31608         this_ptr_conv.is_owned = false;
31609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31610         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
31611         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31612         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31613         return ret_arr;
31614 }
31615
31616 void  __attribute__((visibility("default"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
31617         LDKInvalidShutdownScript this_ptr_conv;
31618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31619         this_ptr_conv.is_owned = false;
31620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31621         LDKCVec_u8Z val_ref;
31622         val_ref.datalen = *((uint32_t*)val);
31623         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31624         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
31625         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
31626 }
31627
31628 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
31629         LDKCVec_u8Z script_arg_ref;
31630         script_arg_ref.datalen = *((uint32_t*)script_arg);
31631         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31632         memcpy(script_arg_ref.data, (uint8_t*)(script_arg + 4), script_arg_ref.datalen);
31633         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
31634         uint64_t ret_ref = 0;
31635         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31636         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31638         ret_ref = (uint64_t)ret_var.inner;
31639         if (ret_var.is_owned) {
31640                 ret_ref |= 1;
31641         }
31642         return ret_ref;
31643 }
31644
31645 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
31646         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
31647 uint64_t ret_ref = 0;
31648 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31649 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31650 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31651 ret_ref = (uint64_t)ret_var.inner;
31652 if (ret_var.is_owned) {
31653         ret_ref |= 1;
31654 }
31655         return ret_ref;
31656 }
31657 int64_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
31658         LDKInvalidShutdownScript arg_conv;
31659         arg_conv.inner = (void*)(arg & (~1));
31660         arg_conv.is_owned = false;
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31662         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
31663         return ret_val;
31664 }
31665
31666 uint32_t  __attribute__((visibility("default"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
31667         LDKInvalidShutdownScript orig_conv;
31668         orig_conv.inner = (void*)(orig & (~1));
31669         orig_conv.is_owned = false;
31670         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31671         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
31672         uint64_t ret_ref = 0;
31673         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31674         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31676         ret_ref = (uint64_t)ret_var.inner;
31677         if (ret_var.is_owned) {
31678                 ret_ref |= 1;
31679         }
31680         return ret_ref;
31681 }
31682
31683 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_write(uint32_t obj) {
31684         LDKShutdownScript obj_conv;
31685         obj_conv.inner = (void*)(obj & (~1));
31686         obj_conv.is_owned = false;
31687         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31688         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
31689         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31690         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31691         CVec_u8Z_free(ret_var);
31692         return ret_arr;
31693 }
31694
31695 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_read(int8_tArray ser) {
31696         LDKu8slice ser_ref;
31697         ser_ref.datalen = *((uint32_t*)ser);
31698         ser_ref.data = (int8_t*)(ser + 4);
31699         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
31700         *ret_conv = ShutdownScript_read(ser_ref);
31701         return (uint64_t)ret_conv;
31702 }
31703
31704 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
31705         unsigned char pubkey_hash_arr[20];
31706         CHECK(*((uint32_t*)pubkey_hash) == 20);
31707         memcpy(pubkey_hash_arr, (uint8_t*)(pubkey_hash + 4), 20);
31708         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
31709         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
31710         uint64_t ret_ref = 0;
31711         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31712         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31714         ret_ref = (uint64_t)ret_var.inner;
31715         if (ret_var.is_owned) {
31716                 ret_ref |= 1;
31717         }
31718         return ret_ref;
31719 }
31720
31721 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
31722         unsigned char script_hash_arr[32];
31723         CHECK(*((uint32_t*)script_hash) == 32);
31724         memcpy(script_hash_arr, (uint8_t*)(script_hash + 4), 32);
31725         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
31726         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
31727         uint64_t ret_ref = 0;
31728         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31729         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31731         ret_ref = (uint64_t)ret_var.inner;
31732         if (ret_var.is_owned) {
31733                 ret_ref |= 1;
31734         }
31735         return ret_ref;
31736 }
31737
31738 uint32_t  __attribute__((visibility("default"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
31739         LDKu8slice program_ref;
31740         program_ref.datalen = *((uint32_t*)program);
31741         program_ref.data = (int8_t*)(program + 4);
31742         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
31743         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
31744         return (uint64_t)ret_conv;
31745 }
31746
31747 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
31748         LDKShutdownScript this_arg_conv;
31749         this_arg_conv.inner = (void*)(this_arg & (~1));
31750         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31752         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
31753         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
31754         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31755         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31756         CVec_u8Z_free(ret_var);
31757         return ret_arr;
31758 }
31759
31760 int8_tArray  __attribute__((visibility("default"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
31761         LDKShutdownScript this_arg_conv;
31762         this_arg_conv.inner = (void*)(this_arg & (~1));
31763         this_arg_conv.is_owned = false;
31764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31765         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
31766         memcpy((uint8_t*)(ret_arr + 4), ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
31767         return ret_arr;
31768 }
31769
31770 jboolean  __attribute__((visibility("default"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
31771         LDKShutdownScript this_arg_conv;
31772         this_arg_conv.inner = (void*)(this_arg & (~1));
31773         this_arg_conv.is_owned = false;
31774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31775         LDKInitFeatures features_conv;
31776         features_conv.inner = (void*)(features & (~1));
31777         features_conv.is_owned = false;
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
31779         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
31780         return ret_val;
31781 }
31782
31783 void  __attribute__((visibility("default"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
31784         if ((this_ptr & 1) != 0) return;
31785         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31786         CHECK_ACCESS(this_ptr_ptr);
31787         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
31788         FREE((void*)this_ptr);
31789         CustomMessageReader_free(this_ptr_conv);
31790 }
31791
31792 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
31793         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31794         *ret_ret = Type_clone(arg);
31795         return (uint64_t)ret_ret;
31796 }
31797 int64_t  __attribute__((visibility("default"))) TS_Type_clone_ptr(uint32_t arg) {
31798         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
31799         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31800         LDKType* arg_conv = (LDKType*)arg_ptr;
31801         int64_t ret_val = Type_clone_ptr(arg_conv);
31802         return ret_val;
31803 }
31804
31805 uint32_t  __attribute__((visibility("default"))) TS_Type_clone(uint32_t orig) {
31806         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
31807         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31808         LDKType* orig_conv = (LDKType*)orig_ptr;
31809         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31810         *ret_ret = Type_clone(orig_conv);
31811         return (uint64_t)ret_ret;
31812 }
31813
31814 void  __attribute__((visibility("default"))) TS_Type_free(uint32_t this_ptr) {
31815         if ((this_ptr & 1) != 0) return;
31816         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31817         CHECK_ACCESS(this_ptr_ptr);
31818         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
31819         FREE((void*)this_ptr);
31820         Type_free(this_ptr_conv);
31821 }
31822
31823 void  __attribute__((visibility("default"))) TS_NodeId_free(uint32_t this_obj) {
31824         LDKNodeId this_obj_conv;
31825         this_obj_conv.inner = (void*)(this_obj & (~1));
31826         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31828         NodeId_free(this_obj_conv);
31829 }
31830
31831 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
31832         LDKNodeId ret_var = NodeId_clone(arg);
31833 uint64_t ret_ref = 0;
31834 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31835 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31836 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31837 ret_ref = (uint64_t)ret_var.inner;
31838 if (ret_var.is_owned) {
31839         ret_ref |= 1;
31840 }
31841         return ret_ref;
31842 }
31843 int64_t  __attribute__((visibility("default"))) TS_NodeId_clone_ptr(uint32_t arg) {
31844         LDKNodeId arg_conv;
31845         arg_conv.inner = (void*)(arg & (~1));
31846         arg_conv.is_owned = false;
31847         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31848         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
31849         return ret_val;
31850 }
31851
31852 uint32_t  __attribute__((visibility("default"))) TS_NodeId_clone(uint32_t orig) {
31853         LDKNodeId orig_conv;
31854         orig_conv.inner = (void*)(orig & (~1));
31855         orig_conv.is_owned = false;
31856         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31857         LDKNodeId ret_var = NodeId_clone(&orig_conv);
31858         uint64_t ret_ref = 0;
31859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31862         ret_ref = (uint64_t)ret_var.inner;
31863         if (ret_var.is_owned) {
31864                 ret_ref |= 1;
31865         }
31866         return ret_ref;
31867 }
31868
31869 uint32_t  __attribute__((visibility("default"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
31870         LDKPublicKey pubkey_ref;
31871         CHECK(*((uint32_t*)pubkey) == 33);
31872         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
31873         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
31874         uint64_t ret_ref = 0;
31875         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31876         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31878         ret_ref = (uint64_t)ret_var.inner;
31879         if (ret_var.is_owned) {
31880                 ret_ref |= 1;
31881         }
31882         return ret_ref;
31883 }
31884
31885 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_as_slice(uint32_t this_arg) {
31886         LDKNodeId this_arg_conv;
31887         this_arg_conv.inner = (void*)(this_arg & (~1));
31888         this_arg_conv.is_owned = false;
31889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31890         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
31891         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31892         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31893         return ret_arr;
31894 }
31895
31896 int64_t  __attribute__((visibility("default"))) TS_NodeId_hash(uint32_t o) {
31897         LDKNodeId o_conv;
31898         o_conv.inner = (void*)(o & (~1));
31899         o_conv.is_owned = false;
31900         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
31901         int64_t ret_val = NodeId_hash(&o_conv);
31902         return ret_val;
31903 }
31904
31905 int8_tArray  __attribute__((visibility("default"))) TS_NodeId_write(uint32_t obj) {
31906         LDKNodeId obj_conv;
31907         obj_conv.inner = (void*)(obj & (~1));
31908         obj_conv.is_owned = false;
31909         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31910         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
31911         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
31912         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
31913         CVec_u8Z_free(ret_var);
31914         return ret_arr;
31915 }
31916
31917 uint32_t  __attribute__((visibility("default"))) TS_NodeId_read(int8_tArray ser) {
31918         LDKu8slice ser_ref;
31919         ser_ref.datalen = *((uint32_t*)ser);
31920         ser_ref.data = (int8_t*)(ser + 4);
31921         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
31922         *ret_conv = NodeId_read(ser_ref);
31923         return (uint64_t)ret_conv;
31924 }
31925
31926 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_obj) {
31927         LDKNetworkGraph this_obj_conv;
31928         this_obj_conv.inner = (void*)(this_obj & (~1));
31929         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31931         NetworkGraph_free(this_obj_conv);
31932 }
31933
31934 static inline uint64_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
31935         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
31936 uint64_t ret_ref = 0;
31937 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31938 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31939 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31940 ret_ref = (uint64_t)ret_var.inner;
31941 if (ret_var.is_owned) {
31942         ret_ref |= 1;
31943 }
31944         return ret_ref;
31945 }
31946 int64_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
31947         LDKNetworkGraph arg_conv;
31948         arg_conv.inner = (void*)(arg & (~1));
31949         arg_conv.is_owned = false;
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31951         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
31952         return ret_val;
31953 }
31954
31955 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_clone(uint32_t orig) {
31956         LDKNetworkGraph orig_conv;
31957         orig_conv.inner = (void*)(orig & (~1));
31958         orig_conv.is_owned = false;
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31960         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
31961         uint64_t ret_ref = 0;
31962         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31963         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31965         ret_ref = (uint64_t)ret_var.inner;
31966         if (ret_var.is_owned) {
31967                 ret_ref |= 1;
31968         }
31969         return ret_ref;
31970 }
31971
31972 void  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
31973         LDKReadOnlyNetworkGraph this_obj_conv;
31974         this_obj_conv.inner = (void*)(this_obj & (~1));
31975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31977         ReadOnlyNetworkGraph_free(this_obj_conv);
31978 }
31979
31980 void  __attribute__((visibility("default"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
31981         if ((this_ptr & 1) != 0) return;
31982         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31983         CHECK_ACCESS(this_ptr_ptr);
31984         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
31985         FREE((void*)this_ptr);
31986         NetworkUpdate_free(this_ptr_conv);
31987 }
31988
31989 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
31990         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31991         *ret_copy = NetworkUpdate_clone(arg);
31992 uint64_t ret_ref = (uint64_t)ret_copy;
31993         return ret_ref;
31994 }
31995 int64_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
31996         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
31997         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
31998         return ret_val;
31999 }
32000
32001 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_clone(uint32_t orig) {
32002         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
32003         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
32004         *ret_copy = NetworkUpdate_clone(orig_conv);
32005         uint64_t ret_ref = (uint64_t)ret_copy;
32006         return ret_ref;
32007 }
32008
32009 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
32010         LDKChannelUpdate msg_conv;
32011         msg_conv.inner = (void*)(msg & (~1));
32012         msg_conv.is_owned = (msg & 1) || (msg == 0);
32013         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32014         msg_conv = ChannelUpdate_clone(&msg_conv);
32015         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
32016         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
32017         uint64_t ret_ref = (uint64_t)ret_copy;
32018         return ret_ref;
32019 }
32020
32021 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
32022         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
32023         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
32024         uint64_t ret_ref = (uint64_t)ret_copy;
32025         return ret_ref;
32026 }
32027
32028 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
32029         LDKPublicKey node_id_ref;
32030         CHECK(*((uint32_t*)node_id) == 33);
32031         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
32032         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
32033         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
32034         uint64_t ret_ref = (uint64_t)ret_copy;
32035         return ret_ref;
32036 }
32037
32038 int8_tArray  __attribute__((visibility("default"))) TS_NetworkUpdate_write(uint32_t obj) {
32039         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
32040         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
32041         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32042         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32043         CVec_u8Z_free(ret_var);
32044         return ret_arr;
32045 }
32046
32047 uint32_t  __attribute__((visibility("default"))) TS_NetworkUpdate_read(int8_tArray ser) {
32048         LDKu8slice ser_ref;
32049         ser_ref.datalen = *((uint32_t*)ser);
32050         ser_ref.data = (int8_t*)(ser + 4);
32051         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
32052         *ret_conv = NetworkUpdate_read(ser_ref);
32053         return (uint64_t)ret_conv;
32054 }
32055
32056 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
32057         LDKNetGraphMsgHandler this_arg_conv;
32058         this_arg_conv.inner = (void*)(this_arg & (~1));
32059         this_arg_conv.is_owned = false;
32060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32061         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
32062         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
32063         return (uint64_t)ret_ret;
32064 }
32065
32066 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
32067         LDKNetGraphMsgHandler this_obj_conv;
32068         this_obj_conv.inner = (void*)(this_obj & (~1));
32069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32071         NetGraphMsgHandler_free(this_obj_conv);
32072 }
32073
32074 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
32075         LDKNetworkGraph network_graph_conv;
32076         network_graph_conv.inner = (void*)(network_graph & (~1));
32077         network_graph_conv.is_owned = false;
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
32079         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
32080         CHECK_ACCESS(chain_access_ptr);
32081         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
32082         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
32083         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
32084                 // Manually implement clone for Java trait instances
32085         }
32086         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
32087         CHECK_ACCESS(logger_ptr);
32088         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32089         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
32090         uint64_t ret_ref = 0;
32091         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32092         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32094         ret_ref = (uint64_t)ret_var.inner;
32095         if (ret_var.is_owned) {
32096                 ret_ref |= 1;
32097         }
32098         return ret_ref;
32099 }
32100
32101 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
32102         LDKNetGraphMsgHandler this_arg_conv;
32103         this_arg_conv.inner = (void*)(this_arg & (~1));
32104         this_arg_conv.is_owned = false;
32105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32106         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
32107         CHECK_ACCESS(chain_access_ptr);
32108         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
32109         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
32110         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
32111                 // Manually implement clone for Java trait instances
32112         }
32113         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
32114 }
32115
32116 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
32117         LDKNetGraphMsgHandler this_arg_conv;
32118         this_arg_conv.inner = (void*)(this_arg & (~1));
32119         this_arg_conv.is_owned = false;
32120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32121         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
32122         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
32123         return (uint64_t)ret_ret;
32124 }
32125
32126 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32127         LDKNetGraphMsgHandler this_arg_conv;
32128         this_arg_conv.inner = (void*)(this_arg & (~1));
32129         this_arg_conv.is_owned = false;
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32131         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32132         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
32133         return (uint64_t)ret_ret;
32134 }
32135
32136 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
32137         LDKDirectionalChannelInfo this_obj_conv;
32138         this_obj_conv.inner = (void*)(this_obj & (~1));
32139         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32141         DirectionalChannelInfo_free(this_obj_conv);
32142 }
32143
32144 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
32145         LDKDirectionalChannelInfo this_ptr_conv;
32146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32147         this_ptr_conv.is_owned = false;
32148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32149         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
32150         return ret_val;
32151 }
32152
32153 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32154         LDKDirectionalChannelInfo this_ptr_conv;
32155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32156         this_ptr_conv.is_owned = false;
32157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32158         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
32159 }
32160
32161 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
32162         LDKDirectionalChannelInfo this_ptr_conv;
32163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32164         this_ptr_conv.is_owned = false;
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32166         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
32167         return ret_val;
32168 }
32169
32170 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
32171         LDKDirectionalChannelInfo this_ptr_conv;
32172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32173         this_ptr_conv.is_owned = false;
32174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32175         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
32176 }
32177
32178 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
32179         LDKDirectionalChannelInfo this_ptr_conv;
32180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32181         this_ptr_conv.is_owned = false;
32182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32183         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
32184         return ret_val;
32185 }
32186
32187 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32188         LDKDirectionalChannelInfo this_ptr_conv;
32189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32190         this_ptr_conv.is_owned = false;
32191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32192         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
32193 }
32194
32195 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
32196         LDKDirectionalChannelInfo this_ptr_conv;
32197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32198         this_ptr_conv.is_owned = false;
32199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32200         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
32201         return ret_val;
32202 }
32203
32204 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32205         LDKDirectionalChannelInfo this_ptr_conv;
32206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32207         this_ptr_conv.is_owned = false;
32208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32209         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
32210 }
32211
32212 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
32213         LDKDirectionalChannelInfo this_ptr_conv;
32214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32215         this_ptr_conv.is_owned = false;
32216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32217         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32218         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
32219         uint64_t ret_ref = (uint64_t)ret_copy;
32220         return ret_ref;
32221 }
32222
32223 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
32224         LDKDirectionalChannelInfo this_ptr_conv;
32225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32226         this_ptr_conv.is_owned = false;
32227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32228         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32229         CHECK_ACCESS(val_ptr);
32230         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32231         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
32232         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
32233 }
32234
32235 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
32236         LDKDirectionalChannelInfo this_ptr_conv;
32237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32238         this_ptr_conv.is_owned = false;
32239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32240         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
32241         uint64_t ret_ref = 0;
32242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32245         ret_ref = (uint64_t)ret_var.inner;
32246         if (ret_var.is_owned) {
32247                 ret_ref |= 1;
32248         }
32249         return ret_ref;
32250 }
32251
32252 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
32253         LDKDirectionalChannelInfo this_ptr_conv;
32254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32255         this_ptr_conv.is_owned = false;
32256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32257         LDKRoutingFees val_conv;
32258         val_conv.inner = (void*)(val & (~1));
32259         val_conv.is_owned = (val & 1) || (val == 0);
32260         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32261         val_conv = RoutingFees_clone(&val_conv);
32262         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
32263 }
32264
32265 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
32266         LDKDirectionalChannelInfo this_ptr_conv;
32267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32268         this_ptr_conv.is_owned = false;
32269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32270         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
32271         uint64_t ret_ref = 0;
32272         if ((uint64_t)ret_var.inner > 4096) {
32273                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32274                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32276                 ret_ref = (uint64_t)ret_var.inner;
32277                 if (ret_var.is_owned) {
32278                         ret_ref |= 1;
32279                 }
32280         }
32281         return ret_ref;
32282 }
32283
32284 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
32285         LDKDirectionalChannelInfo this_ptr_conv;
32286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32287         this_ptr_conv.is_owned = false;
32288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32289         LDKChannelUpdate val_conv;
32290         val_conv.inner = (void*)(val & (~1));
32291         val_conv.is_owned = (val & 1) || (val == 0);
32292         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32293         val_conv = ChannelUpdate_clone(&val_conv);
32294         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
32295 }
32296
32297 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_new(int32_t last_update_arg, jboolean enabled_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) {
32298         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
32299         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
32300         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
32301         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
32302         LDKRoutingFees fees_arg_conv;
32303         fees_arg_conv.inner = (void*)(fees_arg & (~1));
32304         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
32305         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
32306         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
32307         LDKChannelUpdate last_update_message_arg_conv;
32308         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
32309         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
32310         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
32311         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
32312         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
32313         uint64_t ret_ref = 0;
32314         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32315         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32317         ret_ref = (uint64_t)ret_var.inner;
32318         if (ret_var.is_owned) {
32319                 ret_ref |= 1;
32320         }
32321         return ret_ref;
32322 }
32323
32324 static inline uint64_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
32325         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
32326 uint64_t ret_ref = 0;
32327 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32328 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32329 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32330 ret_ref = (uint64_t)ret_var.inner;
32331 if (ret_var.is_owned) {
32332         ret_ref |= 1;
32333 }
32334         return ret_ref;
32335 }
32336 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone_ptr(uint32_t arg) {
32337         LDKDirectionalChannelInfo arg_conv;
32338         arg_conv.inner = (void*)(arg & (~1));
32339         arg_conv.is_owned = false;
32340         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32341         int64_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
32342         return ret_val;
32343 }
32344
32345 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
32346         LDKDirectionalChannelInfo orig_conv;
32347         orig_conv.inner = (void*)(orig & (~1));
32348         orig_conv.is_owned = false;
32349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32350         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
32351         uint64_t ret_ref = 0;
32352         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32353         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32355         ret_ref = (uint64_t)ret_var.inner;
32356         if (ret_var.is_owned) {
32357                 ret_ref |= 1;
32358         }
32359         return ret_ref;
32360 }
32361
32362 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
32363         LDKDirectionalChannelInfo obj_conv;
32364         obj_conv.inner = (void*)(obj & (~1));
32365         obj_conv.is_owned = false;
32366         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32367         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
32368         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32369         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32370         CVec_u8Z_free(ret_var);
32371         return ret_arr;
32372 }
32373
32374 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
32375         LDKu8slice ser_ref;
32376         ser_ref.datalen = *((uint32_t*)ser);
32377         ser_ref.data = (int8_t*)(ser + 4);
32378         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
32379         *ret_conv = DirectionalChannelInfo_read(ser_ref);
32380         return (uint64_t)ret_conv;
32381 }
32382
32383 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_obj) {
32384         LDKChannelInfo this_obj_conv;
32385         this_obj_conv.inner = (void*)(this_obj & (~1));
32386         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32388         ChannelInfo_free(this_obj_conv);
32389 }
32390
32391 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
32392         LDKChannelInfo this_ptr_conv;
32393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32394         this_ptr_conv.is_owned = false;
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
32397         uint64_t ret_ref = 0;
32398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32401         ret_ref = (uint64_t)ret_var.inner;
32402         if (ret_var.is_owned) {
32403                 ret_ref |= 1;
32404         }
32405         return ret_ref;
32406 }
32407
32408 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
32409         LDKChannelInfo this_ptr_conv;
32410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32411         this_ptr_conv.is_owned = false;
32412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32413         LDKChannelFeatures val_conv;
32414         val_conv.inner = (void*)(val & (~1));
32415         val_conv.is_owned = (val & 1) || (val == 0);
32416         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32417         val_conv = ChannelFeatures_clone(&val_conv);
32418         ChannelInfo_set_features(&this_ptr_conv, val_conv);
32419 }
32420
32421 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
32422         LDKChannelInfo this_ptr_conv;
32423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32424         this_ptr_conv.is_owned = false;
32425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32426         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
32427         uint64_t ret_ref = 0;
32428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32431         ret_ref = (uint64_t)ret_var.inner;
32432         if (ret_var.is_owned) {
32433                 ret_ref |= 1;
32434         }
32435         return ret_ref;
32436 }
32437
32438 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
32439         LDKChannelInfo this_ptr_conv;
32440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32441         this_ptr_conv.is_owned = false;
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         LDKNodeId val_conv;
32444         val_conv.inner = (void*)(val & (~1));
32445         val_conv.is_owned = (val & 1) || (val == 0);
32446         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32447         val_conv = NodeId_clone(&val_conv);
32448         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
32449 }
32450
32451 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
32452         LDKChannelInfo this_ptr_conv;
32453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32454         this_ptr_conv.is_owned = false;
32455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32456         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
32457         uint64_t ret_ref = 0;
32458         if ((uint64_t)ret_var.inner > 4096) {
32459                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32460                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32462                 ret_ref = (uint64_t)ret_var.inner;
32463                 if (ret_var.is_owned) {
32464                         ret_ref |= 1;
32465                 }
32466         }
32467         return ret_ref;
32468 }
32469
32470 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
32471         LDKChannelInfo this_ptr_conv;
32472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32473         this_ptr_conv.is_owned = false;
32474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32475         LDKDirectionalChannelInfo val_conv;
32476         val_conv.inner = (void*)(val & (~1));
32477         val_conv.is_owned = (val & 1) || (val == 0);
32478         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32479         val_conv = DirectionalChannelInfo_clone(&val_conv);
32480         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
32481 }
32482
32483 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
32484         LDKChannelInfo this_ptr_conv;
32485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32486         this_ptr_conv.is_owned = false;
32487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32488         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
32489         uint64_t ret_ref = 0;
32490         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32491         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32493         ret_ref = (uint64_t)ret_var.inner;
32494         if (ret_var.is_owned) {
32495                 ret_ref |= 1;
32496         }
32497         return ret_ref;
32498 }
32499
32500 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
32501         LDKChannelInfo this_ptr_conv;
32502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32503         this_ptr_conv.is_owned = false;
32504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32505         LDKNodeId val_conv;
32506         val_conv.inner = (void*)(val & (~1));
32507         val_conv.is_owned = (val & 1) || (val == 0);
32508         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32509         val_conv = NodeId_clone(&val_conv);
32510         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
32511 }
32512
32513 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
32514         LDKChannelInfo this_ptr_conv;
32515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32516         this_ptr_conv.is_owned = false;
32517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32518         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
32519         uint64_t ret_ref = 0;
32520         if ((uint64_t)ret_var.inner > 4096) {
32521                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32522                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32524                 ret_ref = (uint64_t)ret_var.inner;
32525                 if (ret_var.is_owned) {
32526                         ret_ref |= 1;
32527                 }
32528         }
32529         return ret_ref;
32530 }
32531
32532 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
32533         LDKChannelInfo this_ptr_conv;
32534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32535         this_ptr_conv.is_owned = false;
32536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32537         LDKDirectionalChannelInfo val_conv;
32538         val_conv.inner = (void*)(val & (~1));
32539         val_conv.is_owned = (val & 1) || (val == 0);
32540         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32541         val_conv = DirectionalChannelInfo_clone(&val_conv);
32542         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
32543 }
32544
32545 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
32546         LDKChannelInfo this_ptr_conv;
32547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32548         this_ptr_conv.is_owned = false;
32549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32550         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32551         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
32552         uint64_t ret_ref = (uint64_t)ret_copy;
32553         return ret_ref;
32554 }
32555
32556 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
32557         LDKChannelInfo this_ptr_conv;
32558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32559         this_ptr_conv.is_owned = false;
32560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32561         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32562         CHECK_ACCESS(val_ptr);
32563         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32564         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
32565         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
32566 }
32567
32568 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
32569         LDKChannelInfo this_ptr_conv;
32570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32571         this_ptr_conv.is_owned = false;
32572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32573         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
32574         uint64_t ret_ref = 0;
32575         if ((uint64_t)ret_var.inner > 4096) {
32576                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32577                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32579                 ret_ref = (uint64_t)ret_var.inner;
32580                 if (ret_var.is_owned) {
32581                         ret_ref |= 1;
32582                 }
32583         }
32584         return ret_ref;
32585 }
32586
32587 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32588         LDKChannelInfo this_ptr_conv;
32589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32590         this_ptr_conv.is_owned = false;
32591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32592         LDKChannelAnnouncement val_conv;
32593         val_conv.inner = (void*)(val & (~1));
32594         val_conv.is_owned = (val & 1) || (val == 0);
32595         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32596         val_conv = ChannelAnnouncement_clone(&val_conv);
32597         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
32598 }
32599
32600 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
32601         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
32602 uint64_t ret_ref = 0;
32603 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32604 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32606 ret_ref = (uint64_t)ret_var.inner;
32607 if (ret_var.is_owned) {
32608         ret_ref |= 1;
32609 }
32610         return ret_ref;
32611 }
32612 int64_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
32613         LDKChannelInfo arg_conv;
32614         arg_conv.inner = (void*)(arg & (~1));
32615         arg_conv.is_owned = false;
32616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32617         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
32618         return ret_val;
32619 }
32620
32621 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_clone(uint32_t orig) {
32622         LDKChannelInfo orig_conv;
32623         orig_conv.inner = (void*)(orig & (~1));
32624         orig_conv.is_owned = false;
32625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32626         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
32627         uint64_t ret_ref = 0;
32628         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32629         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32631         ret_ref = (uint64_t)ret_var.inner;
32632         if (ret_var.is_owned) {
32633                 ret_ref |= 1;
32634         }
32635         return ret_ref;
32636 }
32637
32638 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
32639         LDKChannelInfo obj_conv;
32640         obj_conv.inner = (void*)(obj & (~1));
32641         obj_conv.is_owned = false;
32642         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32643         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
32644         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32645         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32646         CVec_u8Z_free(ret_var);
32647         return ret_arr;
32648 }
32649
32650 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
32651         LDKu8slice ser_ref;
32652         ser_ref.datalen = *((uint32_t*)ser);
32653         ser_ref.data = (int8_t*)(ser + 4);
32654         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
32655         *ret_conv = ChannelInfo_read(ser_ref);
32656         return (uint64_t)ret_conv;
32657 }
32658
32659 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_obj) {
32660         LDKRoutingFees this_obj_conv;
32661         this_obj_conv.inner = (void*)(this_obj & (~1));
32662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32664         RoutingFees_free(this_obj_conv);
32665 }
32666
32667 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
32668         LDKRoutingFees this_ptr_conv;
32669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32670         this_ptr_conv.is_owned = false;
32671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32672         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
32673         return ret_val;
32674 }
32675
32676 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
32677         LDKRoutingFees this_ptr_conv;
32678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32679         this_ptr_conv.is_owned = false;
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32681         RoutingFees_set_base_msat(&this_ptr_conv, val);
32682 }
32683
32684 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
32685         LDKRoutingFees this_ptr_conv;
32686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32687         this_ptr_conv.is_owned = false;
32688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32689         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
32690         return ret_val;
32691 }
32692
32693 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
32694         LDKRoutingFees this_ptr_conv;
32695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32696         this_ptr_conv.is_owned = false;
32697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32698         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
32699 }
32700
32701 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
32702         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
32703         uint64_t ret_ref = 0;
32704         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32705         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32707         ret_ref = (uint64_t)ret_var.inner;
32708         if (ret_var.is_owned) {
32709                 ret_ref |= 1;
32710         }
32711         return ret_ref;
32712 }
32713
32714 jboolean  __attribute__((visibility("default"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
32715         LDKRoutingFees a_conv;
32716         a_conv.inner = (void*)(a & (~1));
32717         a_conv.is_owned = false;
32718         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32719         LDKRoutingFees b_conv;
32720         b_conv.inner = (void*)(b & (~1));
32721         b_conv.is_owned = false;
32722         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32723         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
32724         return ret_val;
32725 }
32726
32727 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
32728         LDKRoutingFees ret_var = RoutingFees_clone(arg);
32729 uint64_t ret_ref = 0;
32730 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32731 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32732 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32733 ret_ref = (uint64_t)ret_var.inner;
32734 if (ret_var.is_owned) {
32735         ret_ref |= 1;
32736 }
32737         return ret_ref;
32738 }
32739 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
32740         LDKRoutingFees arg_conv;
32741         arg_conv.inner = (void*)(arg & (~1));
32742         arg_conv.is_owned = false;
32743         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32744         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
32745         return ret_val;
32746 }
32747
32748 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
32749         LDKRoutingFees orig_conv;
32750         orig_conv.inner = (void*)(orig & (~1));
32751         orig_conv.is_owned = false;
32752         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32753         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
32754         uint64_t ret_ref = 0;
32755         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32756         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32758         ret_ref = (uint64_t)ret_var.inner;
32759         if (ret_var.is_owned) {
32760                 ret_ref |= 1;
32761         }
32762         return ret_ref;
32763 }
32764
32765 int64_t  __attribute__((visibility("default"))) TS_RoutingFees_hash(uint32_t o) {
32766         LDKRoutingFees o_conv;
32767         o_conv.inner = (void*)(o & (~1));
32768         o_conv.is_owned = false;
32769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32770         int64_t ret_val = RoutingFees_hash(&o_conv);
32771         return ret_val;
32772 }
32773
32774 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
32775         LDKRoutingFees obj_conv;
32776         obj_conv.inner = (void*)(obj & (~1));
32777         obj_conv.is_owned = false;
32778         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32779         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
32780         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
32781         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
32782         CVec_u8Z_free(ret_var);
32783         return ret_arr;
32784 }
32785
32786 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
32787         LDKu8slice ser_ref;
32788         ser_ref.datalen = *((uint32_t*)ser);
32789         ser_ref.data = (int8_t*)(ser + 4);
32790         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
32791         *ret_conv = RoutingFees_read(ser_ref);
32792         return (uint64_t)ret_conv;
32793 }
32794
32795 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
32796         LDKNodeAnnouncementInfo this_obj_conv;
32797         this_obj_conv.inner = (void*)(this_obj & (~1));
32798         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32800         NodeAnnouncementInfo_free(this_obj_conv);
32801 }
32802
32803 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
32804         LDKNodeAnnouncementInfo this_ptr_conv;
32805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32806         this_ptr_conv.is_owned = false;
32807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32808         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
32809         uint64_t ret_ref = 0;
32810         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32811         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32813         ret_ref = (uint64_t)ret_var.inner;
32814         if (ret_var.is_owned) {
32815                 ret_ref |= 1;
32816         }
32817         return ret_ref;
32818 }
32819
32820 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
32821         LDKNodeAnnouncementInfo this_ptr_conv;
32822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32823         this_ptr_conv.is_owned = false;
32824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32825         LDKNodeFeatures val_conv;
32826         val_conv.inner = (void*)(val & (~1));
32827         val_conv.is_owned = (val & 1) || (val == 0);
32828         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32829         val_conv = NodeFeatures_clone(&val_conv);
32830         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
32831 }
32832
32833 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
32834         LDKNodeAnnouncementInfo this_ptr_conv;
32835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32836         this_ptr_conv.is_owned = false;
32837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32838         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
32839         return ret_val;
32840 }
32841
32842 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32843         LDKNodeAnnouncementInfo this_ptr_conv;
32844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32845         this_ptr_conv.is_owned = false;
32846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32847         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
32848 }
32849
32850 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
32851         LDKNodeAnnouncementInfo this_ptr_conv;
32852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32853         this_ptr_conv.is_owned = false;
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32855         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
32856         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
32857         return ret_arr;
32858 }
32859
32860 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
32861         LDKNodeAnnouncementInfo this_ptr_conv;
32862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32863         this_ptr_conv.is_owned = false;
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32865         LDKThreeBytes val_ref;
32866         CHECK(*((uint32_t*)val) == 3);
32867         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
32868         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
32869 }
32870
32871 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
32872         LDKNodeAnnouncementInfo this_ptr_conv;
32873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32874         this_ptr_conv.is_owned = false;
32875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32876         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
32877         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
32878         return ret_arr;
32879 }
32880
32881 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
32882         LDKNodeAnnouncementInfo this_ptr_conv;
32883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32884         this_ptr_conv.is_owned = false;
32885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32886         LDKThirtyTwoBytes val_ref;
32887         CHECK(*((uint32_t*)val) == 32);
32888         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
32889         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
32890 }
32891
32892 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
32893         LDKNodeAnnouncementInfo this_ptr_conv;
32894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32895         this_ptr_conv.is_owned = false;
32896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32897         LDKCVec_NetAddressZ val_constr;
32898         val_constr.datalen = *((uint32_t*)val);
32899         if (val_constr.datalen > 0)
32900                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32901         else
32902                 val_constr.data = NULL;
32903         uint32_t* val_vals = (uint32_t*)(val + 4);
32904         for (size_t m = 0; m < val_constr.datalen; m++) {
32905                 uint32_t val_conv_12 = val_vals[m];
32906                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
32907                 CHECK_ACCESS(val_conv_12_ptr);
32908                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32909                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
32910                 val_constr.data[m] = val_conv_12_conv;
32911         }
32912         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
32913 }
32914
32915 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
32916         LDKNodeAnnouncementInfo this_ptr_conv;
32917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32918         this_ptr_conv.is_owned = false;
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32920         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
32921         uint64_t ret_ref = 0;
32922         if ((uint64_t)ret_var.inner > 4096) {
32923                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32924                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32926                 ret_ref = (uint64_t)ret_var.inner;
32927                 if (ret_var.is_owned) {
32928                         ret_ref |= 1;
32929                 }
32930         }
32931         return ret_ref;
32932 }
32933
32934 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32935         LDKNodeAnnouncementInfo this_ptr_conv;
32936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32937         this_ptr_conv.is_owned = false;
32938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32939         LDKNodeAnnouncement val_conv;
32940         val_conv.inner = (void*)(val & (~1));
32941         val_conv.is_owned = (val & 1) || (val == 0);
32942         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32943         val_conv = NodeAnnouncement_clone(&val_conv);
32944         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
32945 }
32946
32947 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
32948         LDKNodeFeatures features_arg_conv;
32949         features_arg_conv.inner = (void*)(features_arg & (~1));
32950         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
32951         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32952         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
32953         LDKThreeBytes rgb_arg_ref;
32954         CHECK(*((uint32_t*)rgb_arg) == 3);
32955         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
32956         LDKThirtyTwoBytes alias_arg_ref;
32957         CHECK(*((uint32_t*)alias_arg) == 32);
32958         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
32959         LDKCVec_NetAddressZ addresses_arg_constr;
32960         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
32961         if (addresses_arg_constr.datalen > 0)
32962                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32963         else
32964                 addresses_arg_constr.data = NULL;
32965         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
32966         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
32967                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
32968                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
32969                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
32970                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
32971                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
32972         }
32973         LDKNodeAnnouncement announcement_message_arg_conv;
32974         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
32975         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
32976         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
32977         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
32978         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
32979         uint64_t ret_ref = 0;
32980         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32981         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32983         ret_ref = (uint64_t)ret_var.inner;
32984         if (ret_var.is_owned) {
32985                 ret_ref |= 1;
32986         }
32987         return ret_ref;
32988 }
32989
32990 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
32991         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
32992 uint64_t ret_ref = 0;
32993 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32994 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32996 ret_ref = (uint64_t)ret_var.inner;
32997 if (ret_var.is_owned) {
32998         ret_ref |= 1;
32999 }
33000         return ret_ref;
33001 }
33002 int64_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
33003         LDKNodeAnnouncementInfo arg_conv;
33004         arg_conv.inner = (void*)(arg & (~1));
33005         arg_conv.is_owned = false;
33006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33007         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
33008         return ret_val;
33009 }
33010
33011 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
33012         LDKNodeAnnouncementInfo orig_conv;
33013         orig_conv.inner = (void*)(orig & (~1));
33014         orig_conv.is_owned = false;
33015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33016         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
33017         uint64_t ret_ref = 0;
33018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33021         ret_ref = (uint64_t)ret_var.inner;
33022         if (ret_var.is_owned) {
33023                 ret_ref |= 1;
33024         }
33025         return ret_ref;
33026 }
33027
33028 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
33029         LDKNodeAnnouncementInfo obj_conv;
33030         obj_conv.inner = (void*)(obj & (~1));
33031         obj_conv.is_owned = false;
33032         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33033         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
33034         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33035         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33036         CVec_u8Z_free(ret_var);
33037         return ret_arr;
33038 }
33039
33040 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
33041         LDKu8slice ser_ref;
33042         ser_ref.datalen = *((uint32_t*)ser);
33043         ser_ref.data = (int8_t*)(ser + 4);
33044         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
33045         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
33046         return (uint64_t)ret_conv;
33047 }
33048
33049 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_obj) {
33050         LDKNodeInfo this_obj_conv;
33051         this_obj_conv.inner = (void*)(this_obj & (~1));
33052         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33054         NodeInfo_free(this_obj_conv);
33055 }
33056
33057 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
33058         LDKNodeInfo this_ptr_conv;
33059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33060         this_ptr_conv.is_owned = false;
33061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33062         LDKCVec_u64Z val_constr;
33063         val_constr.datalen = *((uint32_t*)val);
33064         if (val_constr.datalen > 0)
33065                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33066         else
33067                 val_constr.data = NULL;
33068         int64_t* val_vals = (int64_t*)(val + 4);
33069         for (size_t i = 0; i < val_constr.datalen; i++) {
33070                 int64_t val_conv_8 = val_vals[i];
33071                 val_constr.data[i] = val_conv_8;
33072         }
33073         NodeInfo_set_channels(&this_ptr_conv, val_constr);
33074 }
33075
33076 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
33077         LDKNodeInfo this_ptr_conv;
33078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33079         this_ptr_conv.is_owned = false;
33080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33081         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
33082         uint64_t ret_ref = 0;
33083         if ((uint64_t)ret_var.inner > 4096) {
33084                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33085                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33087                 ret_ref = (uint64_t)ret_var.inner;
33088                 if (ret_var.is_owned) {
33089                         ret_ref |= 1;
33090                 }
33091         }
33092         return ret_ref;
33093 }
33094
33095 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
33096         LDKNodeInfo this_ptr_conv;
33097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33098         this_ptr_conv.is_owned = false;
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33100         LDKRoutingFees val_conv;
33101         val_conv.inner = (void*)(val & (~1));
33102         val_conv.is_owned = (val & 1) || (val == 0);
33103         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33104         val_conv = RoutingFees_clone(&val_conv);
33105         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
33106 }
33107
33108 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
33109         LDKNodeInfo this_ptr_conv;
33110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33111         this_ptr_conv.is_owned = false;
33112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33113         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
33114         uint64_t ret_ref = 0;
33115         if ((uint64_t)ret_var.inner > 4096) {
33116                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33117                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33119                 ret_ref = (uint64_t)ret_var.inner;
33120                 if (ret_var.is_owned) {
33121                         ret_ref |= 1;
33122                 }
33123         }
33124         return ret_ref;
33125 }
33126
33127 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
33128         LDKNodeInfo this_ptr_conv;
33129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33130         this_ptr_conv.is_owned = false;
33131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33132         LDKNodeAnnouncementInfo val_conv;
33133         val_conv.inner = (void*)(val & (~1));
33134         val_conv.is_owned = (val & 1) || (val == 0);
33135         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33136         val_conv = NodeAnnouncementInfo_clone(&val_conv);
33137         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
33138 }
33139
33140 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
33141         LDKCVec_u64Z channels_arg_constr;
33142         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
33143         if (channels_arg_constr.datalen > 0)
33144                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33145         else
33146                 channels_arg_constr.data = NULL;
33147         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
33148         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
33149                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
33150                 channels_arg_constr.data[i] = channels_arg_conv_8;
33151         }
33152         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
33153         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
33154         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
33155         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
33156         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
33157         LDKNodeAnnouncementInfo announcement_info_arg_conv;
33158         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
33159         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
33160         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
33161         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
33162         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
33163         uint64_t ret_ref = 0;
33164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33167         ret_ref = (uint64_t)ret_var.inner;
33168         if (ret_var.is_owned) {
33169                 ret_ref |= 1;
33170         }
33171         return ret_ref;
33172 }
33173
33174 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
33175         LDKNodeInfo ret_var = NodeInfo_clone(arg);
33176 uint64_t ret_ref = 0;
33177 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33178 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33179 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33180 ret_ref = (uint64_t)ret_var.inner;
33181 if (ret_var.is_owned) {
33182         ret_ref |= 1;
33183 }
33184         return ret_ref;
33185 }
33186 int64_t  __attribute__((visibility("default"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
33187         LDKNodeInfo arg_conv;
33188         arg_conv.inner = (void*)(arg & (~1));
33189         arg_conv.is_owned = false;
33190         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33191         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
33192         return ret_val;
33193 }
33194
33195 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
33196         LDKNodeInfo orig_conv;
33197         orig_conv.inner = (void*)(orig & (~1));
33198         orig_conv.is_owned = false;
33199         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33200         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
33201         uint64_t ret_ref = 0;
33202         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33203         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33205         ret_ref = (uint64_t)ret_var.inner;
33206         if (ret_var.is_owned) {
33207                 ret_ref |= 1;
33208         }
33209         return ret_ref;
33210 }
33211
33212 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
33213         LDKNodeInfo obj_conv;
33214         obj_conv.inner = (void*)(obj & (~1));
33215         obj_conv.is_owned = false;
33216         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33217         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
33218         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33219         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33220         CVec_u8Z_free(ret_var);
33221         return ret_arr;
33222 }
33223
33224 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
33225         LDKu8slice ser_ref;
33226         ser_ref.datalen = *((uint32_t*)ser);
33227         ser_ref.data = (int8_t*)(ser + 4);
33228         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
33229         *ret_conv = NodeInfo_read(ser_ref);
33230         return (uint64_t)ret_conv;
33231 }
33232
33233 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
33234         LDKNetworkGraph obj_conv;
33235         obj_conv.inner = (void*)(obj & (~1));
33236         obj_conv.is_owned = false;
33237         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33238         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
33239         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33240         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33241         CVec_u8Z_free(ret_var);
33242         return ret_arr;
33243 }
33244
33245 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
33246         LDKu8slice ser_ref;
33247         ser_ref.datalen = *((uint32_t*)ser);
33248         ser_ref.data = (int8_t*)(ser + 4);
33249         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
33250         *ret_conv = NetworkGraph_read(ser_ref);
33251         return (uint64_t)ret_conv;
33252 }
33253
33254 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
33255         LDKThirtyTwoBytes genesis_hash_ref;
33256         CHECK(*((uint32_t*)genesis_hash) == 32);
33257         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
33258         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
33259         uint64_t ret_ref = 0;
33260         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33261         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33263         ret_ref = (uint64_t)ret_var.inner;
33264         if (ret_var.is_owned) {
33265                 ret_ref |= 1;
33266         }
33267         return ret_ref;
33268 }
33269
33270 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
33271         LDKNetworkGraph this_arg_conv;
33272         this_arg_conv.inner = (void*)(this_arg & (~1));
33273         this_arg_conv.is_owned = false;
33274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33275         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
33276         uint64_t ret_ref = 0;
33277         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33278         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33280         ret_ref = (uint64_t)ret_var.inner;
33281         if (ret_var.is_owned) {
33282                 ret_ref |= 1;
33283         }
33284         return ret_ref;
33285 }
33286
33287 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
33288         LDKNetworkGraph this_arg_conv;
33289         this_arg_conv.inner = (void*)(this_arg & (~1));
33290         this_arg_conv.is_owned = false;
33291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33292         LDKNodeAnnouncement msg_conv;
33293         msg_conv.inner = (void*)(msg & (~1));
33294         msg_conv.is_owned = false;
33295         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33296         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33297         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
33298         return (uint64_t)ret_conv;
33299 }
33300
33301 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
33302         LDKNetworkGraph this_arg_conv;
33303         this_arg_conv.inner = (void*)(this_arg & (~1));
33304         this_arg_conv.is_owned = false;
33305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33306         LDKUnsignedNodeAnnouncement msg_conv;
33307         msg_conv.inner = (void*)(msg & (~1));
33308         msg_conv.is_owned = false;
33309         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33310         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33311         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
33312         return (uint64_t)ret_conv;
33313 }
33314
33315 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
33316         LDKNetworkGraph this_arg_conv;
33317         this_arg_conv.inner = (void*)(this_arg & (~1));
33318         this_arg_conv.is_owned = false;
33319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33320         LDKChannelAnnouncement msg_conv;
33321         msg_conv.inner = (void*)(msg & (~1));
33322         msg_conv.is_owned = false;
33323         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33324         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
33325         CHECK_ACCESS(chain_access_ptr);
33326         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33327         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33328         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33329                 // Manually implement clone for Java trait instances
33330         }
33331         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33332         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33333         return (uint64_t)ret_conv;
33334 }
33335
33336 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
33337         LDKNetworkGraph this_arg_conv;
33338         this_arg_conv.inner = (void*)(this_arg & (~1));
33339         this_arg_conv.is_owned = false;
33340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33341         LDKUnsignedChannelAnnouncement msg_conv;
33342         msg_conv.inner = (void*)(msg & (~1));
33343         msg_conv.is_owned = false;
33344         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33345         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
33346         CHECK_ACCESS(chain_access_ptr);
33347         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33348         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33349         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33350                 // Manually implement clone for Java trait instances
33351         }
33352         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33353         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33354         return (uint64_t)ret_conv;
33355 }
33356
33357 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
33358         LDKNetworkGraph this_arg_conv;
33359         this_arg_conv.inner = (void*)(this_arg & (~1));
33360         this_arg_conv.is_owned = false;
33361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33362         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
33363 }
33364
33365 void  __attribute__((visibility("default"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
33366         LDKNetworkGraph this_arg_conv;
33367         this_arg_conv.inner = (void*)(this_arg & (~1));
33368         this_arg_conv.is_owned = false;
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33370         LDKPublicKey _node_id_ref;
33371         CHECK(*((uint32_t*)_node_id) == 33);
33372         memcpy(_node_id_ref.compressed_form, (uint8_t*)(_node_id + 4), 33);
33373         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
33374 }
33375
33376 void  __attribute__((visibility("default"))) TS_NetworkGraph_remove_stale_channels_with_time(uint32_t this_arg, int64_t current_time_unix) {
33377         LDKNetworkGraph this_arg_conv;
33378         this_arg_conv.inner = (void*)(this_arg & (~1));
33379         this_arg_conv.is_owned = false;
33380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33381         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
33382 }
33383
33384 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
33385         LDKNetworkGraph this_arg_conv;
33386         this_arg_conv.inner = (void*)(this_arg & (~1));
33387         this_arg_conv.is_owned = false;
33388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33389         LDKChannelUpdate msg_conv;
33390         msg_conv.inner = (void*)(msg & (~1));
33391         msg_conv.is_owned = false;
33392         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33393         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33394         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
33395         return (uint64_t)ret_conv;
33396 }
33397
33398 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
33399         LDKNetworkGraph this_arg_conv;
33400         this_arg_conv.inner = (void*)(this_arg & (~1));
33401         this_arg_conv.is_owned = false;
33402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33403         LDKUnsignedChannelUpdate msg_conv;
33404         msg_conv.inner = (void*)(msg & (~1));
33405         msg_conv.is_owned = false;
33406         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33407         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33408         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
33409         return (uint64_t)ret_conv;
33410 }
33411
33412 uint32_t  __attribute__((visibility("default"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
33413         LDKReadOnlyNetworkGraph this_arg_conv;
33414         this_arg_conv.inner = (void*)(this_arg & (~1));
33415         this_arg_conv.is_owned = false;
33416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33417         LDKPublicKey pubkey_ref;
33418         CHECK(*((uint32_t*)pubkey) == 33);
33419         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
33420         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
33421         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
33422         uint64_t ret_ref = (uint64_t)ret_copy;
33423         return ret_ref;
33424 }
33425
33426 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_obj) {
33427         LDKRouteHop this_obj_conv;
33428         this_obj_conv.inner = (void*)(this_obj & (~1));
33429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33431         RouteHop_free(this_obj_conv);
33432 }
33433
33434 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
33435         LDKRouteHop this_ptr_conv;
33436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33437         this_ptr_conv.is_owned = false;
33438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33439         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
33440         memcpy((uint8_t*)(ret_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
33441         return ret_arr;
33442 }
33443
33444 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33445         LDKRouteHop this_ptr_conv;
33446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33447         this_ptr_conv.is_owned = false;
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33449         LDKPublicKey val_ref;
33450         CHECK(*((uint32_t*)val) == 33);
33451         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
33452         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
33453 }
33454
33455 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
33456         LDKRouteHop this_ptr_conv;
33457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33458         this_ptr_conv.is_owned = false;
33459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33460         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
33461         uint64_t ret_ref = 0;
33462         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33463         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33465         ret_ref = (uint64_t)ret_var.inner;
33466         if (ret_var.is_owned) {
33467                 ret_ref |= 1;
33468         }
33469         return ret_ref;
33470 }
33471
33472 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
33473         LDKRouteHop this_ptr_conv;
33474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33475         this_ptr_conv.is_owned = false;
33476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33477         LDKNodeFeatures val_conv;
33478         val_conv.inner = (void*)(val & (~1));
33479         val_conv.is_owned = (val & 1) || (val == 0);
33480         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33481         val_conv = NodeFeatures_clone(&val_conv);
33482         RouteHop_set_node_features(&this_ptr_conv, val_conv);
33483 }
33484
33485 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
33486         LDKRouteHop this_ptr_conv;
33487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33488         this_ptr_conv.is_owned = false;
33489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33490         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
33491         return ret_val;
33492 }
33493
33494 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
33495         LDKRouteHop this_ptr_conv;
33496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33497         this_ptr_conv.is_owned = false;
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33499         RouteHop_set_short_channel_id(&this_ptr_conv, val);
33500 }
33501
33502 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
33503         LDKRouteHop this_ptr_conv;
33504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33505         this_ptr_conv.is_owned = false;
33506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33507         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
33508         uint64_t ret_ref = 0;
33509         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33510         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33512         ret_ref = (uint64_t)ret_var.inner;
33513         if (ret_var.is_owned) {
33514                 ret_ref |= 1;
33515         }
33516         return ret_ref;
33517 }
33518
33519 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
33520         LDKRouteHop this_ptr_conv;
33521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33522         this_ptr_conv.is_owned = false;
33523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33524         LDKChannelFeatures val_conv;
33525         val_conv.inner = (void*)(val & (~1));
33526         val_conv.is_owned = (val & 1) || (val == 0);
33527         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33528         val_conv = ChannelFeatures_clone(&val_conv);
33529         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
33530 }
33531
33532 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
33533         LDKRouteHop this_ptr_conv;
33534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33535         this_ptr_conv.is_owned = false;
33536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33537         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
33538         return ret_val;
33539 }
33540
33541 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
33542         LDKRouteHop this_ptr_conv;
33543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33544         this_ptr_conv.is_owned = false;
33545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33546         RouteHop_set_fee_msat(&this_ptr_conv, val);
33547 }
33548
33549 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
33550         LDKRouteHop this_ptr_conv;
33551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33552         this_ptr_conv.is_owned = false;
33553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33554         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
33555         return ret_val;
33556 }
33557
33558 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
33559         LDKRouteHop this_ptr_conv;
33560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33561         this_ptr_conv.is_owned = false;
33562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33563         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
33564 }
33565
33566 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_new(int8_tArray pubkey_arg, uint32_t node_features_arg, int64_t short_channel_id_arg, uint32_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
33567         LDKPublicKey pubkey_arg_ref;
33568         CHECK(*((uint32_t*)pubkey_arg) == 33);
33569         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
33570         LDKNodeFeatures node_features_arg_conv;
33571         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
33572         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
33573         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
33574         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
33575         LDKChannelFeatures channel_features_arg_conv;
33576         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
33577         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
33579         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
33580         LDKRouteHop ret_var = RouteHop_new(pubkey_arg_ref, node_features_arg_conv, short_channel_id_arg, channel_features_arg_conv, fee_msat_arg, cltv_expiry_delta_arg);
33581         uint64_t ret_ref = 0;
33582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33585         ret_ref = (uint64_t)ret_var.inner;
33586         if (ret_var.is_owned) {
33587                 ret_ref |= 1;
33588         }
33589         return ret_ref;
33590 }
33591
33592 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
33593         LDKRouteHop ret_var = RouteHop_clone(arg);
33594 uint64_t ret_ref = 0;
33595 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33596 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33597 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33598 ret_ref = (uint64_t)ret_var.inner;
33599 if (ret_var.is_owned) {
33600         ret_ref |= 1;
33601 }
33602         return ret_ref;
33603 }
33604 int64_t  __attribute__((visibility("default"))) TS_RouteHop_clone_ptr(uint32_t arg) {
33605         LDKRouteHop arg_conv;
33606         arg_conv.inner = (void*)(arg & (~1));
33607         arg_conv.is_owned = false;
33608         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33609         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
33610         return ret_val;
33611 }
33612
33613 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
33614         LDKRouteHop orig_conv;
33615         orig_conv.inner = (void*)(orig & (~1));
33616         orig_conv.is_owned = false;
33617         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33618         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
33619         uint64_t ret_ref = 0;
33620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33623         ret_ref = (uint64_t)ret_var.inner;
33624         if (ret_var.is_owned) {
33625                 ret_ref |= 1;
33626         }
33627         return ret_ref;
33628 }
33629
33630 int64_t  __attribute__((visibility("default"))) TS_RouteHop_hash(uint32_t o) {
33631         LDKRouteHop o_conv;
33632         o_conv.inner = (void*)(o & (~1));
33633         o_conv.is_owned = false;
33634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33635         int64_t ret_val = RouteHop_hash(&o_conv);
33636         return ret_val;
33637 }
33638
33639 jboolean  __attribute__((visibility("default"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
33640         LDKRouteHop a_conv;
33641         a_conv.inner = (void*)(a & (~1));
33642         a_conv.is_owned = false;
33643         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33644         LDKRouteHop b_conv;
33645         b_conv.inner = (void*)(b & (~1));
33646         b_conv.is_owned = false;
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33648         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
33649         return ret_val;
33650 }
33651
33652 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_write(uint32_t obj) {
33653         LDKRouteHop obj_conv;
33654         obj_conv.inner = (void*)(obj & (~1));
33655         obj_conv.is_owned = false;
33656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33657         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
33658         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33659         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33660         CVec_u8Z_free(ret_var);
33661         return ret_arr;
33662 }
33663
33664 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_read(int8_tArray ser) {
33665         LDKu8slice ser_ref;
33666         ser_ref.datalen = *((uint32_t*)ser);
33667         ser_ref.data = (int8_t*)(ser + 4);
33668         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
33669         *ret_conv = RouteHop_read(ser_ref);
33670         return (uint64_t)ret_conv;
33671 }
33672
33673 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_obj) {
33674         LDKRoute this_obj_conv;
33675         this_obj_conv.inner = (void*)(this_obj & (~1));
33676         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33678         Route_free(this_obj_conv);
33679 }
33680
33681 ptrArray  __attribute__((visibility("default"))) TS_Route_get_paths(uint32_t this_ptr) {
33682         LDKRoute this_ptr_conv;
33683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33684         this_ptr_conv.is_owned = false;
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33686         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
33687         ptrArray ret_arr = NULL;
33688         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
33689         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(ret_arr + 4);
33690         for (size_t m = 0; m < ret_var.datalen; m++) {
33691                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
33692                 uint32_tArray ret_conv_12_arr = NULL;
33693                 ret_conv_12_arr = init_arr(ret_conv_12_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
33694                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(ret_conv_12_arr + 4);
33695                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
33696                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
33697                         uint64_t ret_conv_12_conv_10_ref = 0;
33698                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33699                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33700                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
33701                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
33702                         if (ret_conv_12_conv_10_var.is_owned) {
33703                                 ret_conv_12_conv_10_ref |= 1;
33704                         }
33705                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
33706                 }
33707                 
33708                 FREE(ret_conv_12_var.data);
33709                 ret_arr_ptr[m] = ret_conv_12_arr;
33710         }
33711         
33712         FREE(ret_var.data);
33713         return ret_arr;
33714 }
33715
33716 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
33717         LDKRoute this_ptr_conv;
33718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33719         this_ptr_conv.is_owned = false;
33720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33721         LDKCVec_CVec_RouteHopZZ val_constr;
33722         val_constr.datalen = *((uint32_t*)val);
33723         if (val_constr.datalen > 0)
33724                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33725         else
33726                 val_constr.data = NULL;
33727         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
33728         for (size_t m = 0; m < val_constr.datalen; m++) {
33729                 uint32_tArray val_conv_12 = val_vals[m];
33730                 LDKCVec_RouteHopZ val_conv_12_constr;
33731                 val_conv_12_constr.datalen = *((uint32_t*)val_conv_12);
33732                 if (val_conv_12_constr.datalen > 0)
33733                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33734                 else
33735                         val_conv_12_constr.data = NULL;
33736                 uint32_t* val_conv_12_vals = (uint32_t*)(val_conv_12 + 4);
33737                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
33738                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
33739                         LDKRouteHop val_conv_12_conv_10_conv;
33740                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
33741                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
33742                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
33743                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
33744                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
33745                 }
33746                 val_constr.data[m] = val_conv_12_constr;
33747         }
33748         Route_set_paths(&this_ptr_conv, val_constr);
33749 }
33750
33751 uint32_t  __attribute__((visibility("default"))) TS_Route_get_payee(uint32_t this_ptr) {
33752         LDKRoute this_ptr_conv;
33753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33754         this_ptr_conv.is_owned = false;
33755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33756         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
33757         uint64_t ret_ref = 0;
33758         if ((uint64_t)ret_var.inner > 4096) {
33759                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33760                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33762                 ret_ref = (uint64_t)ret_var.inner;
33763                 if (ret_var.is_owned) {
33764                         ret_ref |= 1;
33765                 }
33766         }
33767         return ret_ref;
33768 }
33769
33770 void  __attribute__((visibility("default"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
33771         LDKRoute this_ptr_conv;
33772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33773         this_ptr_conv.is_owned = false;
33774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33775         LDKPayee val_conv;
33776         val_conv.inner = (void*)(val & (~1));
33777         val_conv.is_owned = (val & 1) || (val == 0);
33778         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33779         val_conv = Payee_clone(&val_conv);
33780         Route_set_payee(&this_ptr_conv, val_conv);
33781 }
33782
33783 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
33784         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
33785         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
33786         if (paths_arg_constr.datalen > 0)
33787                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33788         else
33789                 paths_arg_constr.data = NULL;
33790         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
33791         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
33792                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
33793                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
33794                 paths_arg_conv_12_constr.datalen = *((uint32_t*)paths_arg_conv_12);
33795                 if (paths_arg_conv_12_constr.datalen > 0)
33796                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33797                 else
33798                         paths_arg_conv_12_constr.data = NULL;
33799                 uint32_t* paths_arg_conv_12_vals = (uint32_t*)(paths_arg_conv_12 + 4);
33800                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
33801                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
33802                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
33803                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
33804                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
33805                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
33806                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
33807                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
33808                 }
33809                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
33810         }
33811         LDKPayee payee_arg_conv;
33812         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33813         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33814         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33815         payee_arg_conv = Payee_clone(&payee_arg_conv);
33816         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
33817         uint64_t ret_ref = 0;
33818         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33819         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33821         ret_ref = (uint64_t)ret_var.inner;
33822         if (ret_var.is_owned) {
33823                 ret_ref |= 1;
33824         }
33825         return ret_ref;
33826 }
33827
33828 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
33829         LDKRoute ret_var = Route_clone(arg);
33830 uint64_t ret_ref = 0;
33831 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33832 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33833 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33834 ret_ref = (uint64_t)ret_var.inner;
33835 if (ret_var.is_owned) {
33836         ret_ref |= 1;
33837 }
33838         return ret_ref;
33839 }
33840 int64_t  __attribute__((visibility("default"))) TS_Route_clone_ptr(uint32_t arg) {
33841         LDKRoute arg_conv;
33842         arg_conv.inner = (void*)(arg & (~1));
33843         arg_conv.is_owned = false;
33844         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33845         int64_t ret_val = Route_clone_ptr(&arg_conv);
33846         return ret_val;
33847 }
33848
33849 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
33850         LDKRoute orig_conv;
33851         orig_conv.inner = (void*)(orig & (~1));
33852         orig_conv.is_owned = false;
33853         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33854         LDKRoute ret_var = Route_clone(&orig_conv);
33855         uint64_t ret_ref = 0;
33856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33859         ret_ref = (uint64_t)ret_var.inner;
33860         if (ret_var.is_owned) {
33861                 ret_ref |= 1;
33862         }
33863         return ret_ref;
33864 }
33865
33866 int64_t  __attribute__((visibility("default"))) TS_Route_hash(uint32_t o) {
33867         LDKRoute o_conv;
33868         o_conv.inner = (void*)(o & (~1));
33869         o_conv.is_owned = false;
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33871         int64_t ret_val = Route_hash(&o_conv);
33872         return ret_val;
33873 }
33874
33875 jboolean  __attribute__((visibility("default"))) TS_Route_eq(uint32_t a, uint32_t b) {
33876         LDKRoute a_conv;
33877         a_conv.inner = (void*)(a & (~1));
33878         a_conv.is_owned = false;
33879         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33880         LDKRoute b_conv;
33881         b_conv.inner = (void*)(b & (~1));
33882         b_conv.is_owned = false;
33883         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33884         jboolean ret_val = Route_eq(&a_conv, &b_conv);
33885         return ret_val;
33886 }
33887
33888 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_fees(uint32_t this_arg) {
33889         LDKRoute this_arg_conv;
33890         this_arg_conv.inner = (void*)(this_arg & (~1));
33891         this_arg_conv.is_owned = false;
33892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33893         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
33894         return ret_val;
33895 }
33896
33897 int64_t  __attribute__((visibility("default"))) TS_Route_get_total_amount(uint32_t this_arg) {
33898         LDKRoute this_arg_conv;
33899         this_arg_conv.inner = (void*)(this_arg & (~1));
33900         this_arg_conv.is_owned = false;
33901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33902         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
33903         return ret_val;
33904 }
33905
33906 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
33907         LDKRoute obj_conv;
33908         obj_conv.inner = (void*)(obj & (~1));
33909         obj_conv.is_owned = false;
33910         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33911         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
33912         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
33913         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
33914         CVec_u8Z_free(ret_var);
33915         return ret_arr;
33916 }
33917
33918 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
33919         LDKu8slice ser_ref;
33920         ser_ref.datalen = *((uint32_t*)ser);
33921         ser_ref.data = (int8_t*)(ser + 4);
33922         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
33923         *ret_conv = Route_read(ser_ref);
33924         return (uint64_t)ret_conv;
33925 }
33926
33927 void  __attribute__((visibility("default"))) TS_RouteParameters_free(uint32_t this_obj) {
33928         LDKRouteParameters this_obj_conv;
33929         this_obj_conv.inner = (void*)(this_obj & (~1));
33930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33932         RouteParameters_free(this_obj_conv);
33933 }
33934
33935 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
33936         LDKRouteParameters this_ptr_conv;
33937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33938         this_ptr_conv.is_owned = false;
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33940         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
33941         uint64_t ret_ref = 0;
33942         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33943         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33945         ret_ref = (uint64_t)ret_var.inner;
33946         if (ret_var.is_owned) {
33947                 ret_ref |= 1;
33948         }
33949         return ret_ref;
33950 }
33951
33952 void  __attribute__((visibility("default"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
33953         LDKRouteParameters this_ptr_conv;
33954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33955         this_ptr_conv.is_owned = false;
33956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33957         LDKPayee val_conv;
33958         val_conv.inner = (void*)(val & (~1));
33959         val_conv.is_owned = (val & 1) || (val == 0);
33960         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33961         val_conv = Payee_clone(&val_conv);
33962         RouteParameters_set_payee(&this_ptr_conv, val_conv);
33963 }
33964
33965 int64_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
33966         LDKRouteParameters this_ptr_conv;
33967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33968         this_ptr_conv.is_owned = false;
33969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33970         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
33971         return ret_val;
33972 }
33973
33974 void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
33975         LDKRouteParameters this_ptr_conv;
33976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33977         this_ptr_conv.is_owned = false;
33978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33979         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
33980 }
33981
33982 int32_t  __attribute__((visibility("default"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
33983         LDKRouteParameters this_ptr_conv;
33984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33985         this_ptr_conv.is_owned = false;
33986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33987         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
33988         return ret_val;
33989 }
33990
33991 void  __attribute__((visibility("default"))) TS_RouteParameters_set_final_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
33992         LDKRouteParameters this_ptr_conv;
33993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33994         this_ptr_conv.is_owned = false;
33995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33996         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
33997 }
33998
33999 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_new(uint32_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
34000         LDKPayee payee_arg_conv;
34001         payee_arg_conv.inner = (void*)(payee_arg & (~1));
34002         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
34004         payee_arg_conv = Payee_clone(&payee_arg_conv);
34005         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
34006         uint64_t ret_ref = 0;
34007         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34008         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34010         ret_ref = (uint64_t)ret_var.inner;
34011         if (ret_var.is_owned) {
34012                 ret_ref |= 1;
34013         }
34014         return ret_ref;
34015 }
34016
34017 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
34018         LDKRouteParameters ret_var = RouteParameters_clone(arg);
34019 uint64_t ret_ref = 0;
34020 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34021 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34023 ret_ref = (uint64_t)ret_var.inner;
34024 if (ret_var.is_owned) {
34025         ret_ref |= 1;
34026 }
34027         return ret_ref;
34028 }
34029 int64_t  __attribute__((visibility("default"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
34030         LDKRouteParameters arg_conv;
34031         arg_conv.inner = (void*)(arg & (~1));
34032         arg_conv.is_owned = false;
34033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34034         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
34035         return ret_val;
34036 }
34037
34038 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_clone(uint32_t orig) {
34039         LDKRouteParameters orig_conv;
34040         orig_conv.inner = (void*)(orig & (~1));
34041         orig_conv.is_owned = false;
34042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34043         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
34044         uint64_t ret_ref = 0;
34045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34048         ret_ref = (uint64_t)ret_var.inner;
34049         if (ret_var.is_owned) {
34050                 ret_ref |= 1;
34051         }
34052         return ret_ref;
34053 }
34054
34055 int8_tArray  __attribute__((visibility("default"))) TS_RouteParameters_write(uint32_t obj) {
34056         LDKRouteParameters obj_conv;
34057         obj_conv.inner = (void*)(obj & (~1));
34058         obj_conv.is_owned = false;
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34060         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
34061         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34062         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34063         CVec_u8Z_free(ret_var);
34064         return ret_arr;
34065 }
34066
34067 uint32_t  __attribute__((visibility("default"))) TS_RouteParameters_read(int8_tArray ser) {
34068         LDKu8slice ser_ref;
34069         ser_ref.datalen = *((uint32_t*)ser);
34070         ser_ref.data = (int8_t*)(ser + 4);
34071         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
34072         *ret_conv = RouteParameters_read(ser_ref);
34073         return (uint64_t)ret_conv;
34074 }
34075
34076 void  __attribute__((visibility("default"))) TS_Payee_free(uint32_t this_obj) {
34077         LDKPayee this_obj_conv;
34078         this_obj_conv.inner = (void*)(this_obj & (~1));
34079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34081         Payee_free(this_obj_conv);
34082 }
34083
34084 int8_tArray  __attribute__((visibility("default"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
34085         LDKPayee this_ptr_conv;
34086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34087         this_ptr_conv.is_owned = false;
34088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34089         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
34090         memcpy((uint8_t*)(ret_arr + 4), Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
34091         return ret_arr;
34092 }
34093
34094 void  __attribute__((visibility("default"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
34095         LDKPayee this_ptr_conv;
34096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34097         this_ptr_conv.is_owned = false;
34098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34099         LDKPublicKey val_ref;
34100         CHECK(*((uint32_t*)val) == 33);
34101         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
34102         Payee_set_pubkey(&this_ptr_conv, val_ref);
34103 }
34104
34105 uint32_t  __attribute__((visibility("default"))) TS_Payee_get_features(uint32_t this_ptr) {
34106         LDKPayee this_ptr_conv;
34107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34108         this_ptr_conv.is_owned = false;
34109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34110         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
34111         uint64_t ret_ref = 0;
34112         if ((uint64_t)ret_var.inner > 4096) {
34113                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34114                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34116                 ret_ref = (uint64_t)ret_var.inner;
34117                 if (ret_var.is_owned) {
34118                         ret_ref |= 1;
34119                 }
34120         }
34121         return ret_ref;
34122 }
34123
34124 void  __attribute__((visibility("default"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
34125         LDKPayee this_ptr_conv;
34126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34127         this_ptr_conv.is_owned = false;
34128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34129         LDKInvoiceFeatures val_conv;
34130         val_conv.inner = (void*)(val & (~1));
34131         val_conv.is_owned = (val & 1) || (val == 0);
34132         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34133         val_conv = InvoiceFeatures_clone(&val_conv);
34134         Payee_set_features(&this_ptr_conv, val_conv);
34135 }
34136
34137 uint32_tArray  __attribute__((visibility("default"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
34138         LDKPayee this_ptr_conv;
34139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34140         this_ptr_conv.is_owned = false;
34141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34142         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
34143         uint32_tArray ret_arr = NULL;
34144         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
34145         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
34146         for (size_t l = 0; l < ret_var.datalen; l++) {
34147                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
34148                 uint64_t ret_conv_11_ref = 0;
34149                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34150                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34151                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
34152                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
34153                 if (ret_conv_11_var.is_owned) {
34154                         ret_conv_11_ref |= 1;
34155                 }
34156                 ret_arr_ptr[l] = ret_conv_11_ref;
34157         }
34158         
34159         FREE(ret_var.data);
34160         return ret_arr;
34161 }
34162
34163 void  __attribute__((visibility("default"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
34164         LDKPayee this_ptr_conv;
34165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34166         this_ptr_conv.is_owned = false;
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34168         LDKCVec_RouteHintZ val_constr;
34169         val_constr.datalen = *((uint32_t*)val);
34170         if (val_constr.datalen > 0)
34171                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34172         else
34173                 val_constr.data = NULL;
34174         uint32_t* val_vals = (uint32_t*)(val + 4);
34175         for (size_t l = 0; l < val_constr.datalen; l++) {
34176                 uint32_t val_conv_11 = val_vals[l];
34177                 LDKRouteHint val_conv_11_conv;
34178                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
34179                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
34180                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
34181                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
34182                 val_constr.data[l] = val_conv_11_conv;
34183         }
34184         Payee_set_route_hints(&this_ptr_conv, val_constr);
34185 }
34186
34187 uint32_t  __attribute__((visibility("default"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
34188         LDKPayee this_ptr_conv;
34189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34190         this_ptr_conv.is_owned = false;
34191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34192         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34193         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
34194         uint64_t ret_ref = (uint64_t)ret_copy;
34195         return ret_ref;
34196 }
34197
34198 void  __attribute__((visibility("default"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
34199         LDKPayee this_ptr_conv;
34200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34201         this_ptr_conv.is_owned = false;
34202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34203         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34204         CHECK_ACCESS(val_ptr);
34205         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34206         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34207         Payee_set_expiry_time(&this_ptr_conv, val_conv);
34208 }
34209
34210 uint32_t  __attribute__((visibility("default"))) TS_Payee_new(int8_tArray pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg) {
34211         LDKPublicKey pubkey_arg_ref;
34212         CHECK(*((uint32_t*)pubkey_arg) == 33);
34213         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
34214         LDKInvoiceFeatures features_arg_conv;
34215         features_arg_conv.inner = (void*)(features_arg & (~1));
34216         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
34217         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34218         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
34219         LDKCVec_RouteHintZ route_hints_arg_constr;
34220         route_hints_arg_constr.datalen = *((uint32_t*)route_hints_arg);
34221         if (route_hints_arg_constr.datalen > 0)
34222                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34223         else
34224                 route_hints_arg_constr.data = NULL;
34225         uint32_t* route_hints_arg_vals = (uint32_t*)(route_hints_arg + 4);
34226         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
34227                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
34228                 LDKRouteHint route_hints_arg_conv_11_conv;
34229                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
34230                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
34231                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
34232                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
34233                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
34234         }
34235         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
34236         CHECK_ACCESS(expiry_time_arg_ptr);
34237         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
34238         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
34239         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
34240         uint64_t ret_ref = 0;
34241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34244         ret_ref = (uint64_t)ret_var.inner;
34245         if (ret_var.is_owned) {
34246                 ret_ref |= 1;
34247         }
34248         return ret_ref;
34249 }
34250
34251 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
34252         LDKPayee ret_var = Payee_clone(arg);
34253 uint64_t ret_ref = 0;
34254 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34255 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34256 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34257 ret_ref = (uint64_t)ret_var.inner;
34258 if (ret_var.is_owned) {
34259         ret_ref |= 1;
34260 }
34261         return ret_ref;
34262 }
34263 int64_t  __attribute__((visibility("default"))) TS_Payee_clone_ptr(uint32_t arg) {
34264         LDKPayee arg_conv;
34265         arg_conv.inner = (void*)(arg & (~1));
34266         arg_conv.is_owned = false;
34267         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34268         int64_t ret_val = Payee_clone_ptr(&arg_conv);
34269         return ret_val;
34270 }
34271
34272 uint32_t  __attribute__((visibility("default"))) TS_Payee_clone(uint32_t orig) {
34273         LDKPayee orig_conv;
34274         orig_conv.inner = (void*)(orig & (~1));
34275         orig_conv.is_owned = false;
34276         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34277         LDKPayee ret_var = Payee_clone(&orig_conv);
34278         uint64_t ret_ref = 0;
34279         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34280         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34282         ret_ref = (uint64_t)ret_var.inner;
34283         if (ret_var.is_owned) {
34284                 ret_ref |= 1;
34285         }
34286         return ret_ref;
34287 }
34288
34289 int64_t  __attribute__((visibility("default"))) TS_Payee_hash(uint32_t o) {
34290         LDKPayee o_conv;
34291         o_conv.inner = (void*)(o & (~1));
34292         o_conv.is_owned = false;
34293         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34294         int64_t ret_val = Payee_hash(&o_conv);
34295         return ret_val;
34296 }
34297
34298 jboolean  __attribute__((visibility("default"))) TS_Payee_eq(uint32_t a, uint32_t b) {
34299         LDKPayee a_conv;
34300         a_conv.inner = (void*)(a & (~1));
34301         a_conv.is_owned = false;
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34303         LDKPayee b_conv;
34304         b_conv.inner = (void*)(b & (~1));
34305         b_conv.is_owned = false;
34306         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34307         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
34308         return ret_val;
34309 }
34310
34311 int8_tArray  __attribute__((visibility("default"))) TS_Payee_write(uint32_t obj) {
34312         LDKPayee obj_conv;
34313         obj_conv.inner = (void*)(obj & (~1));
34314         obj_conv.is_owned = false;
34315         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34316         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
34317         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34318         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34319         CVec_u8Z_free(ret_var);
34320         return ret_arr;
34321 }
34322
34323 uint32_t  __attribute__((visibility("default"))) TS_Payee_read(int8_tArray ser) {
34324         LDKu8slice ser_ref;
34325         ser_ref.datalen = *((uint32_t*)ser);
34326         ser_ref.data = (int8_t*)(ser + 4);
34327         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
34328         *ret_conv = Payee_read(ser_ref);
34329         return (uint64_t)ret_conv;
34330 }
34331
34332 uint32_t  __attribute__((visibility("default"))) TS_Payee_from_node_id(int8_tArray pubkey) {
34333         LDKPublicKey pubkey_ref;
34334         CHECK(*((uint32_t*)pubkey) == 33);
34335         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
34336         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
34337         uint64_t ret_ref = 0;
34338         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34339         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34341         ret_ref = (uint64_t)ret_var.inner;
34342         if (ret_var.is_owned) {
34343                 ret_ref |= 1;
34344         }
34345         return ret_ref;
34346 }
34347
34348 uint32_t  __attribute__((visibility("default"))) TS_Payee_for_keysend(int8_tArray pubkey) {
34349         LDKPublicKey pubkey_ref;
34350         CHECK(*((uint32_t*)pubkey) == 33);
34351         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
34352         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
34353         uint64_t ret_ref = 0;
34354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34357         ret_ref = (uint64_t)ret_var.inner;
34358         if (ret_var.is_owned) {
34359                 ret_ref |= 1;
34360         }
34361         return ret_ref;
34362 }
34363
34364 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_obj) {
34365         LDKRouteHint this_obj_conv;
34366         this_obj_conv.inner = (void*)(this_obj & (~1));
34367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34369         RouteHint_free(this_obj_conv);
34370 }
34371
34372 uint32_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_a(uint32_t this_ptr) {
34373         LDKRouteHint this_ptr_conv;
34374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34375         this_ptr_conv.is_owned = false;
34376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34377         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
34378         uint32_tArray ret_arr = NULL;
34379         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
34380         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
34381         for (size_t o = 0; o < ret_var.datalen; o++) {
34382                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
34383                 uint64_t ret_conv_14_ref = 0;
34384                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34385                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34386                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
34387                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
34388                 if (ret_conv_14_var.is_owned) {
34389                         ret_conv_14_ref |= 1;
34390                 }
34391                 ret_arr_ptr[o] = ret_conv_14_ref;
34392         }
34393         
34394         FREE(ret_var.data);
34395         return ret_arr;
34396 }
34397
34398 void  __attribute__((visibility("default"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
34399         LDKRouteHint this_ptr_conv;
34400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34401         this_ptr_conv.is_owned = false;
34402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34403         LDKCVec_RouteHintHopZ val_constr;
34404         val_constr.datalen = *((uint32_t*)val);
34405         if (val_constr.datalen > 0)
34406                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34407         else
34408                 val_constr.data = NULL;
34409         uint32_t* val_vals = (uint32_t*)(val + 4);
34410         for (size_t o = 0; o < val_constr.datalen; o++) {
34411                 uint32_t val_conv_14 = val_vals[o];
34412                 LDKRouteHintHop val_conv_14_conv;
34413                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
34414                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
34415                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
34416                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
34417                 val_constr.data[o] = val_conv_14_conv;
34418         }
34419         RouteHint_set_a(&this_ptr_conv, val_constr);
34420 }
34421
34422 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_new(uint32_tArray a_arg) {
34423         LDKCVec_RouteHintHopZ a_arg_constr;
34424         a_arg_constr.datalen = *((uint32_t*)a_arg);
34425         if (a_arg_constr.datalen > 0)
34426                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34427         else
34428                 a_arg_constr.data = NULL;
34429         uint32_t* a_arg_vals = (uint32_t*)(a_arg + 4);
34430         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
34431                 uint32_t a_arg_conv_14 = a_arg_vals[o];
34432                 LDKRouteHintHop a_arg_conv_14_conv;
34433                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
34434                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
34435                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
34436                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
34437                 a_arg_constr.data[o] = a_arg_conv_14_conv;
34438         }
34439         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
34440         uint64_t ret_ref = 0;
34441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34444         ret_ref = (uint64_t)ret_var.inner;
34445         if (ret_var.is_owned) {
34446                 ret_ref |= 1;
34447         }
34448         return ret_ref;
34449 }
34450
34451 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
34452         LDKRouteHint ret_var = RouteHint_clone(arg);
34453 uint64_t ret_ref = 0;
34454 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34455 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34456 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34457 ret_ref = (uint64_t)ret_var.inner;
34458 if (ret_var.is_owned) {
34459         ret_ref |= 1;
34460 }
34461         return ret_ref;
34462 }
34463 int64_t  __attribute__((visibility("default"))) TS_RouteHint_clone_ptr(uint32_t arg) {
34464         LDKRouteHint arg_conv;
34465         arg_conv.inner = (void*)(arg & (~1));
34466         arg_conv.is_owned = false;
34467         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34468         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
34469         return ret_val;
34470 }
34471
34472 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
34473         LDKRouteHint orig_conv;
34474         orig_conv.inner = (void*)(orig & (~1));
34475         orig_conv.is_owned = false;
34476         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34477         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
34478         uint64_t ret_ref = 0;
34479         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34480         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34482         ret_ref = (uint64_t)ret_var.inner;
34483         if (ret_var.is_owned) {
34484                 ret_ref |= 1;
34485         }
34486         return ret_ref;
34487 }
34488
34489 int64_t  __attribute__((visibility("default"))) TS_RouteHint_hash(uint32_t o) {
34490         LDKRouteHint o_conv;
34491         o_conv.inner = (void*)(o & (~1));
34492         o_conv.is_owned = false;
34493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34494         int64_t ret_val = RouteHint_hash(&o_conv);
34495         return ret_val;
34496 }
34497
34498 jboolean  __attribute__((visibility("default"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
34499         LDKRouteHint a_conv;
34500         a_conv.inner = (void*)(a & (~1));
34501         a_conv.is_owned = false;
34502         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34503         LDKRouteHint b_conv;
34504         b_conv.inner = (void*)(b & (~1));
34505         b_conv.is_owned = false;
34506         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34507         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
34508         return ret_val;
34509 }
34510
34511 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_write(uint32_t obj) {
34512         LDKRouteHint obj_conv;
34513         obj_conv.inner = (void*)(obj & (~1));
34514         obj_conv.is_owned = false;
34515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34516         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
34517         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34518         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34519         CVec_u8Z_free(ret_var);
34520         return ret_arr;
34521 }
34522
34523 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_read(int8_tArray ser) {
34524         LDKu8slice ser_ref;
34525         ser_ref.datalen = *((uint32_t*)ser);
34526         ser_ref.data = (int8_t*)(ser + 4);
34527         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
34528         *ret_conv = RouteHint_read(ser_ref);
34529         return (uint64_t)ret_conv;
34530 }
34531
34532 void  __attribute__((visibility("default"))) TS_RouteHintHop_free(uint32_t this_obj) {
34533         LDKRouteHintHop this_obj_conv;
34534         this_obj_conv.inner = (void*)(this_obj & (~1));
34535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34537         RouteHintHop_free(this_obj_conv);
34538 }
34539
34540 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
34541         LDKRouteHintHop this_ptr_conv;
34542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34543         this_ptr_conv.is_owned = false;
34544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34545         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
34546         memcpy((uint8_t*)(ret_arr + 4), RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
34547         return ret_arr;
34548 }
34549
34550 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
34551         LDKRouteHintHop this_ptr_conv;
34552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34553         this_ptr_conv.is_owned = false;
34554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34555         LDKPublicKey val_ref;
34556         CHECK(*((uint32_t*)val) == 33);
34557         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
34558         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
34559 }
34560
34561 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
34562         LDKRouteHintHop this_ptr_conv;
34563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34564         this_ptr_conv.is_owned = false;
34565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34566         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
34567         return ret_val;
34568 }
34569
34570 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
34571         LDKRouteHintHop this_ptr_conv;
34572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34573         this_ptr_conv.is_owned = false;
34574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34575         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
34576 }
34577
34578 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
34579         LDKRouteHintHop this_ptr_conv;
34580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34581         this_ptr_conv.is_owned = false;
34582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34583         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
34584         uint64_t ret_ref = 0;
34585         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34586         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34588         ret_ref = (uint64_t)ret_var.inner;
34589         if (ret_var.is_owned) {
34590                 ret_ref |= 1;
34591         }
34592         return ret_ref;
34593 }
34594
34595 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
34596         LDKRouteHintHop this_ptr_conv;
34597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34598         this_ptr_conv.is_owned = false;
34599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34600         LDKRoutingFees val_conv;
34601         val_conv.inner = (void*)(val & (~1));
34602         val_conv.is_owned = (val & 1) || (val == 0);
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34604         val_conv = RoutingFees_clone(&val_conv);
34605         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
34606 }
34607
34608 int16_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
34609         LDKRouteHintHop this_ptr_conv;
34610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34611         this_ptr_conv.is_owned = false;
34612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34613         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
34614         return ret_val;
34615 }
34616
34617 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
34618         LDKRouteHintHop this_ptr_conv;
34619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34620         this_ptr_conv.is_owned = false;
34621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34622         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
34623 }
34624
34625 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
34626         LDKRouteHintHop this_ptr_conv;
34627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34628         this_ptr_conv.is_owned = false;
34629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34630         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34631         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
34632         uint64_t ret_ref = (uint64_t)ret_copy;
34633         return ret_ref;
34634 }
34635
34636 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
34637         LDKRouteHintHop this_ptr_conv;
34638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34639         this_ptr_conv.is_owned = false;
34640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34641         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34642         CHECK_ACCESS(val_ptr);
34643         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34644         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34645         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
34646 }
34647
34648 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
34649         LDKRouteHintHop this_ptr_conv;
34650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34651         this_ptr_conv.is_owned = false;
34652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34653         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34654         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
34655         uint64_t ret_ref = (uint64_t)ret_copy;
34656         return ret_ref;
34657 }
34658
34659 void  __attribute__((visibility("default"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
34660         LDKRouteHintHop this_ptr_conv;
34661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34662         this_ptr_conv.is_owned = false;
34663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34664         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34665         CHECK_ACCESS(val_ptr);
34666         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34667         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34668         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
34669 }
34670
34671 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint32_t fees_arg, int16_t cltv_expiry_delta_arg, uint32_t htlc_minimum_msat_arg, uint32_t htlc_maximum_msat_arg) {
34672         LDKPublicKey src_node_id_arg_ref;
34673         CHECK(*((uint32_t*)src_node_id_arg) == 33);
34674         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
34675         LDKRoutingFees fees_arg_conv;
34676         fees_arg_conv.inner = (void*)(fees_arg & (~1));
34677         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
34679         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
34680         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
34681         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
34682         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
34683         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
34684         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
34685         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
34686         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
34687         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
34688         LDKRouteHintHop ret_var = RouteHintHop_new(src_node_id_arg_ref, short_channel_id_arg, fees_arg_conv, cltv_expiry_delta_arg, htlc_minimum_msat_arg_conv, htlc_maximum_msat_arg_conv);
34689         uint64_t ret_ref = 0;
34690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34693         ret_ref = (uint64_t)ret_var.inner;
34694         if (ret_var.is_owned) {
34695                 ret_ref |= 1;
34696         }
34697         return ret_ref;
34698 }
34699
34700 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
34701         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
34702 uint64_t ret_ref = 0;
34703 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34704 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34705 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34706 ret_ref = (uint64_t)ret_var.inner;
34707 if (ret_var.is_owned) {
34708         ret_ref |= 1;
34709 }
34710         return ret_ref;
34711 }
34712 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
34713         LDKRouteHintHop arg_conv;
34714         arg_conv.inner = (void*)(arg & (~1));
34715         arg_conv.is_owned = false;
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34717         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
34718         return ret_val;
34719 }
34720
34721 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_clone(uint32_t orig) {
34722         LDKRouteHintHop orig_conv;
34723         orig_conv.inner = (void*)(orig & (~1));
34724         orig_conv.is_owned = false;
34725         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34726         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
34727         uint64_t ret_ref = 0;
34728         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34729         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34731         ret_ref = (uint64_t)ret_var.inner;
34732         if (ret_var.is_owned) {
34733                 ret_ref |= 1;
34734         }
34735         return ret_ref;
34736 }
34737
34738 int64_t  __attribute__((visibility("default"))) TS_RouteHintHop_hash(uint32_t o) {
34739         LDKRouteHintHop o_conv;
34740         o_conv.inner = (void*)(o & (~1));
34741         o_conv.is_owned = false;
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34743         int64_t ret_val = RouteHintHop_hash(&o_conv);
34744         return ret_val;
34745 }
34746
34747 jboolean  __attribute__((visibility("default"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
34748         LDKRouteHintHop a_conv;
34749         a_conv.inner = (void*)(a & (~1));
34750         a_conv.is_owned = false;
34751         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34752         LDKRouteHintHop b_conv;
34753         b_conv.inner = (void*)(b & (~1));
34754         b_conv.is_owned = false;
34755         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34756         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
34757         return ret_val;
34758 }
34759
34760 int8_tArray  __attribute__((visibility("default"))) TS_RouteHintHop_write(uint32_t obj) {
34761         LDKRouteHintHop obj_conv;
34762         obj_conv.inner = (void*)(obj & (~1));
34763         obj_conv.is_owned = false;
34764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34765         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
34766         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34767         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34768         CVec_u8Z_free(ret_var);
34769         return ret_arr;
34770 }
34771
34772 uint32_t  __attribute__((visibility("default"))) TS_RouteHintHop_read(int8_tArray ser) {
34773         LDKu8slice ser_ref;
34774         ser_ref.datalen = *((uint32_t*)ser);
34775         ser_ref.data = (int8_t*)(ser + 4);
34776         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
34777         *ret_conv = RouteHintHop_read(ser_ref);
34778         return (uint64_t)ret_conv;
34779 }
34780
34781 uint32_t  __attribute__((visibility("default"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer) {
34782         LDKPublicKey our_node_pubkey_ref;
34783         CHECK(*((uint32_t*)our_node_pubkey) == 33);
34784         memcpy(our_node_pubkey_ref.compressed_form, (uint8_t*)(our_node_pubkey + 4), 33);
34785         LDKRouteParameters params_conv;
34786         params_conv.inner = (void*)(params & (~1));
34787         params_conv.is_owned = false;
34788         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
34789         LDKNetworkGraph network_conv;
34790         network_conv.inner = (void*)(network & (~1));
34791         network_conv.is_owned = false;
34792         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
34793         LDKCVec_ChannelDetailsZ first_hops_constr;
34794         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
34795         if (first_hops != 0) {
34796                 first_hops_constr.datalen = *((uint32_t*)first_hops);
34797                 if (first_hops_constr.datalen > 0)
34798                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
34799                 else
34800                         first_hops_constr.data = NULL;
34801                 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
34802                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
34803                         uint32_t first_hops_conv_16 = first_hops_vals[q];
34804                         LDKChannelDetails first_hops_conv_16_conv;
34805                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
34806                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
34807                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
34808                         first_hops_constr.data[q] = first_hops_conv_16_conv;
34809                 }
34810                 first_hops_ptr = &first_hops_constr;
34811         }
34812         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
34813         CHECK_ACCESS(logger_ptr);
34814         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34815         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
34816         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
34817         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
34818         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
34819         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
34820         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
34821         return (uint64_t)ret_conv;
34822 }
34823
34824 void  __attribute__((visibility("default"))) TS_Score_free(uint32_t this_ptr) {
34825         if ((this_ptr & 1) != 0) return;
34826         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34827         CHECK_ACCESS(this_ptr_ptr);
34828         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
34829         FREE((void*)this_ptr);
34830         Score_free(this_ptr_conv);
34831 }
34832
34833 void  __attribute__((visibility("default"))) TS_LockableScore_free(uint32_t this_ptr) {
34834         if ((this_ptr & 1) != 0) return;
34835         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34836         CHECK_ACCESS(this_ptr_ptr);
34837         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
34838         FREE((void*)this_ptr);
34839         LockableScore_free(this_ptr_conv);
34840 }
34841
34842 void  __attribute__((visibility("default"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
34843         LDKMultiThreadedLockableScore this_obj_conv;
34844         this_obj_conv.inner = (void*)(this_obj & (~1));
34845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34847         MultiThreadedLockableScore_free(this_obj_conv);
34848 }
34849
34850 uint32_t  __attribute__((visibility("default"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
34851         void* score_ptr = (void*)(((uint64_t)score) & ~1);
34852         CHECK_ACCESS(score_ptr);
34853         LDKScore score_conv = *(LDKScore*)(score_ptr);
34854         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
34855         uint64_t ret_ref = 0;
34856         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34857         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34859         ret_ref = (uint64_t)ret_var.inner;
34860         if (ret_var.is_owned) {
34861                 ret_ref |= 1;
34862         }
34863         return ret_ref;
34864 }
34865
34866 void  __attribute__((visibility("default"))) TS_Scorer_free(uint32_t this_obj) {
34867         LDKScorer this_obj_conv;
34868         this_obj_conv.inner = (void*)(this_obj & (~1));
34869         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34871         Scorer_free(this_obj_conv);
34872 }
34873
34874 void  __attribute__((visibility("default"))) TS_ScoringParameters_free(uint32_t this_obj) {
34875         LDKScoringParameters this_obj_conv;
34876         this_obj_conv.inner = (void*)(this_obj & (~1));
34877         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34879         ScoringParameters_free(this_obj_conv);
34880 }
34881
34882 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
34883         LDKScoringParameters this_ptr_conv;
34884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34885         this_ptr_conv.is_owned = false;
34886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34887         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
34888         return ret_val;
34889 }
34890
34891 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
34892         LDKScoringParameters this_ptr_conv;
34893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34894         this_ptr_conv.is_owned = false;
34895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34896         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
34897 }
34898
34899 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
34900         LDKScoringParameters this_ptr_conv;
34901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34902         this_ptr_conv.is_owned = false;
34903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34904         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
34905         return ret_val;
34906 }
34907
34908 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
34909         LDKScoringParameters this_ptr_conv;
34910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34911         this_ptr_conv.is_owned = false;
34912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34913         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
34914 }
34915
34916 int16_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
34917         LDKScoringParameters this_ptr_conv;
34918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34919         this_ptr_conv.is_owned = false;
34920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34921         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
34922         return ret_val;
34923 }
34924
34925 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_overuse_penalty_start_1024th(uint32_t this_ptr, int16_t val) {
34926         LDKScoringParameters this_ptr_conv;
34927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34928         this_ptr_conv.is_owned = false;
34929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34930         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
34931 }
34932
34933 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_overuse_penalty_msat_per_1024th(uint32_t this_ptr) {
34934         LDKScoringParameters this_ptr_conv;
34935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34936         this_ptr_conv.is_owned = false;
34937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34938         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
34939         return ret_val;
34940 }
34941
34942 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_overuse_penalty_msat_per_1024th(uint32_t this_ptr, int64_t val) {
34943         LDKScoringParameters this_ptr_conv;
34944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34945         this_ptr_conv.is_owned = false;
34946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34947         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
34948 }
34949
34950 int64_t  __attribute__((visibility("default"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
34951         LDKScoringParameters this_ptr_conv;
34952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34953         this_ptr_conv.is_owned = false;
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34955         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
34956         return ret_val;
34957 }
34958
34959 void  __attribute__((visibility("default"))) TS_ScoringParameters_set_failure_penalty_half_life(uint32_t this_ptr, int64_t val) {
34960         LDKScoringParameters this_ptr_conv;
34961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34962         this_ptr_conv.is_owned = false;
34963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34964         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
34965 }
34966
34967 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_new(int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
34968         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
34969         uint64_t ret_ref = 0;
34970         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34971         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34973         ret_ref = (uint64_t)ret_var.inner;
34974         if (ret_var.is_owned) {
34975                 ret_ref |= 1;
34976         }
34977         return ret_ref;
34978 }
34979
34980 int8_tArray  __attribute__((visibility("default"))) TS_ScoringParameters_write(uint32_t obj) {
34981         LDKScoringParameters obj_conv;
34982         obj_conv.inner = (void*)(obj & (~1));
34983         obj_conv.is_owned = false;
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34985         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
34986         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
34987         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
34988         CVec_u8Z_free(ret_var);
34989         return ret_arr;
34990 }
34991
34992 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_read(int8_tArray ser) {
34993         LDKu8slice ser_ref;
34994         ser_ref.datalen = *((uint32_t*)ser);
34995         ser_ref.data = (int8_t*)(ser + 4);
34996         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
34997         *ret_conv = ScoringParameters_read(ser_ref);
34998         return (uint64_t)ret_conv;
34999 }
35000
35001 uint32_t  __attribute__((visibility("default"))) TS_Scorer_new(uint32_t params) {
35002         LDKScoringParameters params_conv;
35003         params_conv.inner = (void*)(params & (~1));
35004         params_conv.is_owned = (params & 1) || (params == 0);
35005         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
35006         // Warning: we need a move here but no clone is available for LDKScoringParameters
35007         LDKScorer ret_var = Scorer_new(params_conv);
35008         uint64_t ret_ref = 0;
35009         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35010         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35012         ret_ref = (uint64_t)ret_var.inner;
35013         if (ret_var.is_owned) {
35014                 ret_ref |= 1;
35015         }
35016         return ret_ref;
35017 }
35018
35019 uint32_t  __attribute__((visibility("default"))) TS_Scorer_default() {
35020         LDKScorer ret_var = Scorer_default();
35021         uint64_t ret_ref = 0;
35022         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35023         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35025         ret_ref = (uint64_t)ret_var.inner;
35026         if (ret_var.is_owned) {
35027                 ret_ref |= 1;
35028         }
35029         return ret_ref;
35030 }
35031
35032 uint32_t  __attribute__((visibility("default"))) TS_ScoringParameters_default() {
35033         LDKScoringParameters ret_var = ScoringParameters_default();
35034         uint64_t ret_ref = 0;
35035         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35036         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35038         ret_ref = (uint64_t)ret_var.inner;
35039         if (ret_var.is_owned) {
35040                 ret_ref |= 1;
35041         }
35042         return ret_ref;
35043 }
35044
35045 uint32_t  __attribute__((visibility("default"))) TS_Scorer_as_Score(uint32_t this_arg) {
35046         LDKScorer this_arg_conv;
35047         this_arg_conv.inner = (void*)(this_arg & (~1));
35048         this_arg_conv.is_owned = false;
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35050         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
35051         *ret_ret = Scorer_as_Score(&this_arg_conv);
35052         return (uint64_t)ret_ret;
35053 }
35054
35055 int8_tArray  __attribute__((visibility("default"))) TS_Scorer_write(uint32_t obj) {
35056         LDKScorer obj_conv;
35057         obj_conv.inner = (void*)(obj & (~1));
35058         obj_conv.is_owned = false;
35059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35060         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
35061         int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
35062         memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
35063         CVec_u8Z_free(ret_var);
35064         return ret_arr;
35065 }
35066
35067 uint32_t  __attribute__((visibility("default"))) TS_Scorer_read(int8_tArray ser) {
35068         LDKu8slice ser_ref;
35069         ser_ref.datalen = *((uint32_t*)ser);
35070         ser_ref.data = (int8_t*)(ser + 4);
35071         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
35072         *ret_conv = Scorer_read(ser_ref);
35073         return (uint64_t)ret_conv;
35074 }
35075
35076 void  __attribute__((visibility("default"))) TS_FilesystemPersister_free(uint32_t this_obj) {
35077         LDKFilesystemPersister this_obj_conv;
35078         this_obj_conv.inner = (void*)(this_obj & (~1));
35079         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35081         FilesystemPersister_free(this_obj_conv);
35082 }
35083
35084 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_new(jstring path_to_channel_data) {
35085         LDKStr path_to_channel_data_conv = str_ref_to_owned_c(path_to_channel_data);
35086         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
35087         uint64_t ret_ref = 0;
35088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35091         ret_ref = (uint64_t)ret_var.inner;
35092         if (ret_var.is_owned) {
35093                 ret_ref |= 1;
35094         }
35095         return ret_ref;
35096 }
35097
35098 jstring  __attribute__((visibility("default"))) TS_FilesystemPersister_get_data_dir(uint32_t this_arg) {
35099         LDKFilesystemPersister this_arg_conv;
35100         this_arg_conv.inner = (void*)(this_arg & (~1));
35101         this_arg_conv.is_owned = false;
35102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35103         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
35104         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
35105         Str_free(ret_str);
35106         return ret_conv;
35107 }
35108
35109 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_persist_manager(jstring data_dir, uint32_t manager) {
35110         LDKStr data_dir_conv = str_ref_to_owned_c(data_dir);
35111         LDKChannelManager manager_conv;
35112         manager_conv.inner = (void*)(manager & (~1));
35113         manager_conv.is_owned = false;
35114         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
35115         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
35116         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
35117         return (uint64_t)ret_conv;
35118 }
35119
35120 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_read_channelmonitors(uint32_t this_arg, uint32_t keys_manager) {
35121         LDKFilesystemPersister this_arg_conv;
35122         this_arg_conv.inner = (void*)(this_arg & (~1));
35123         this_arg_conv.is_owned = false;
35124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35125         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
35126         CHECK_ACCESS(keys_manager_ptr);
35127         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
35128         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
35129         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
35130         return (uint64_t)ret_conv;
35131 }
35132
35133 uint32_t  __attribute__((visibility("default"))) TS_FilesystemPersister_as_Persist(uint32_t this_arg) {
35134         LDKFilesystemPersister this_arg_conv;
35135         this_arg_conv.inner = (void*)(this_arg & (~1));
35136         this_arg_conv.is_owned = false;
35137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35138         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
35139         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
35140         return (uint64_t)ret_ret;
35141 }
35142
35143 void  __attribute__((visibility("default"))) TS_BackgroundProcessor_free(uint32_t this_obj) {
35144         LDKBackgroundProcessor this_obj_conv;
35145         this_obj_conv.inner = (void*)(this_obj & (~1));
35146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35148         BackgroundProcessor_free(this_obj_conv);
35149 }
35150
35151 void  __attribute__((visibility("default"))) TS_ChannelManagerPersister_free(uint32_t this_ptr) {
35152         if ((this_ptr & 1) != 0) return;
35153         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
35154         CHECK_ACCESS(this_ptr_ptr);
35155         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
35156         FREE((void*)this_ptr);
35157         ChannelManagerPersister_free(this_ptr_conv);
35158 }
35159
35160 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_start(uint32_t persister, uint32_t event_handler, uint32_t chain_monitor, uint32_t channel_manager, uint32_t net_graph_msg_handler, uint32_t peer_manager, uint32_t logger) {
35161         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
35162         CHECK_ACCESS(persister_ptr);
35163         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
35164         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
35165         CHECK_ACCESS(event_handler_ptr);
35166         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
35167         LDKChainMonitor chain_monitor_conv;
35168         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
35169         chain_monitor_conv.is_owned = false;
35170         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
35171         LDKChannelManager channel_manager_conv;
35172         channel_manager_conv.inner = (void*)(channel_manager & (~1));
35173         channel_manager_conv.is_owned = false;
35174         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
35175         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
35176         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
35177         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
35179         LDKPeerManager peer_manager_conv;
35180         peer_manager_conv.inner = (void*)(peer_manager & (~1));
35181         peer_manager_conv.is_owned = false;
35182         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
35183         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
35184         CHECK_ACCESS(logger_ptr);
35185         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
35186         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
35187         uint64_t ret_ref = 0;
35188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35191         ret_ref = (uint64_t)ret_var.inner;
35192         if (ret_var.is_owned) {
35193                 ret_ref |= 1;
35194         }
35195         return ret_ref;
35196 }
35197
35198 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_join(uint32_t this_arg) {
35199         LDKBackgroundProcessor this_arg_conv;
35200         this_arg_conv.inner = (void*)(this_arg & (~1));
35201         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35203         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
35204         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
35205         *ret_conv = BackgroundProcessor_join(this_arg_conv);
35206         return (uint64_t)ret_conv;
35207 }
35208
35209 uint32_t  __attribute__((visibility("default"))) TS_BackgroundProcessor_stop(uint32_t this_arg) {
35210         LDKBackgroundProcessor this_arg_conv;
35211         this_arg_conv.inner = (void*)(this_arg & (~1));
35212         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35214         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
35215         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
35216         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
35217         return (uint64_t)ret_conv;
35218 }
35219
35220 void  __attribute__((visibility("default"))) TS_check_platform() {
35221         check_platform();
35222 }
35223
35224 void  __attribute__((visibility("default"))) TS_Invoice_free(uint32_t this_obj) {
35225         LDKInvoice this_obj_conv;
35226         this_obj_conv.inner = (void*)(this_obj & (~1));
35227         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35229         Invoice_free(this_obj_conv);
35230 }
35231
35232 jboolean  __attribute__((visibility("default"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
35233         LDKInvoice a_conv;
35234         a_conv.inner = (void*)(a & (~1));
35235         a_conv.is_owned = false;
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35237         LDKInvoice b_conv;
35238         b_conv.inner = (void*)(b & (~1));
35239         b_conv.is_owned = false;
35240         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35241         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
35242         return ret_val;
35243 }
35244
35245 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
35246         LDKInvoice ret_var = Invoice_clone(arg);
35247 uint64_t ret_ref = 0;
35248 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35249 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35250 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35251 ret_ref = (uint64_t)ret_var.inner;
35252 if (ret_var.is_owned) {
35253         ret_ref |= 1;
35254 }
35255         return ret_ref;
35256 }
35257 int64_t  __attribute__((visibility("default"))) TS_Invoice_clone_ptr(uint32_t arg) {
35258         LDKInvoice arg_conv;
35259         arg_conv.inner = (void*)(arg & (~1));
35260         arg_conv.is_owned = false;
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35262         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
35263         return ret_val;
35264 }
35265
35266 uint32_t  __attribute__((visibility("default"))) TS_Invoice_clone(uint32_t orig) {
35267         LDKInvoice orig_conv;
35268         orig_conv.inner = (void*)(orig & (~1));
35269         orig_conv.is_owned = false;
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35271         LDKInvoice ret_var = Invoice_clone(&orig_conv);
35272         uint64_t ret_ref = 0;
35273         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35274         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35276         ret_ref = (uint64_t)ret_var.inner;
35277         if (ret_var.is_owned) {
35278                 ret_ref |= 1;
35279         }
35280         return ret_ref;
35281 }
35282
35283 void  __attribute__((visibility("default"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
35284         LDKSignedRawInvoice this_obj_conv;
35285         this_obj_conv.inner = (void*)(this_obj & (~1));
35286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35288         SignedRawInvoice_free(this_obj_conv);
35289 }
35290
35291 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
35292         LDKSignedRawInvoice a_conv;
35293         a_conv.inner = (void*)(a & (~1));
35294         a_conv.is_owned = false;
35295         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35296         LDKSignedRawInvoice b_conv;
35297         b_conv.inner = (void*)(b & (~1));
35298         b_conv.is_owned = false;
35299         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35300         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
35301         return ret_val;
35302 }
35303
35304 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
35305         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
35306 uint64_t ret_ref = 0;
35307 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35308 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35309 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35310 ret_ref = (uint64_t)ret_var.inner;
35311 if (ret_var.is_owned) {
35312         ret_ref |= 1;
35313 }
35314         return ret_ref;
35315 }
35316 int64_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
35317         LDKSignedRawInvoice arg_conv;
35318         arg_conv.inner = (void*)(arg & (~1));
35319         arg_conv.is_owned = false;
35320         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35321         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
35322         return ret_val;
35323 }
35324
35325 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_clone(uint32_t orig) {
35326         LDKSignedRawInvoice orig_conv;
35327         orig_conv.inner = (void*)(orig & (~1));
35328         orig_conv.is_owned = false;
35329         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35330         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
35331         uint64_t ret_ref = 0;
35332         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35333         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35335         ret_ref = (uint64_t)ret_var.inner;
35336         if (ret_var.is_owned) {
35337                 ret_ref |= 1;
35338         }
35339         return ret_ref;
35340 }
35341
35342 void  __attribute__((visibility("default"))) TS_RawInvoice_free(uint32_t this_obj) {
35343         LDKRawInvoice this_obj_conv;
35344         this_obj_conv.inner = (void*)(this_obj & (~1));
35345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35347         RawInvoice_free(this_obj_conv);
35348 }
35349
35350 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
35351         LDKRawInvoice this_ptr_conv;
35352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35353         this_ptr_conv.is_owned = false;
35354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35355         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
35356         uint64_t ret_ref = 0;
35357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35360         ret_ref = (uint64_t)ret_var.inner;
35361         if (ret_var.is_owned) {
35362                 ret_ref |= 1;
35363         }
35364         return ret_ref;
35365 }
35366
35367 void  __attribute__((visibility("default"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
35368         LDKRawInvoice this_ptr_conv;
35369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35370         this_ptr_conv.is_owned = false;
35371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35372         LDKRawDataPart val_conv;
35373         val_conv.inner = (void*)(val & (~1));
35374         val_conv.is_owned = (val & 1) || (val == 0);
35375         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35376         val_conv = RawDataPart_clone(&val_conv);
35377         RawInvoice_set_data(&this_ptr_conv, val_conv);
35378 }
35379
35380 jboolean  __attribute__((visibility("default"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
35381         LDKRawInvoice a_conv;
35382         a_conv.inner = (void*)(a & (~1));
35383         a_conv.is_owned = false;
35384         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35385         LDKRawInvoice b_conv;
35386         b_conv.inner = (void*)(b & (~1));
35387         b_conv.is_owned = false;
35388         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35389         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
35390         return ret_val;
35391 }
35392
35393 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
35394         LDKRawInvoice ret_var = RawInvoice_clone(arg);
35395 uint64_t ret_ref = 0;
35396 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35397 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35399 ret_ref = (uint64_t)ret_var.inner;
35400 if (ret_var.is_owned) {
35401         ret_ref |= 1;
35402 }
35403         return ret_ref;
35404 }
35405 int64_t  __attribute__((visibility("default"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
35406         LDKRawInvoice arg_conv;
35407         arg_conv.inner = (void*)(arg & (~1));
35408         arg_conv.is_owned = false;
35409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35410         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
35411         return ret_val;
35412 }
35413
35414 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_clone(uint32_t orig) {
35415         LDKRawInvoice orig_conv;
35416         orig_conv.inner = (void*)(orig & (~1));
35417         orig_conv.is_owned = false;
35418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35419         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
35420         uint64_t ret_ref = 0;
35421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35424         ret_ref = (uint64_t)ret_var.inner;
35425         if (ret_var.is_owned) {
35426                 ret_ref |= 1;
35427         }
35428         return ret_ref;
35429 }
35430
35431 void  __attribute__((visibility("default"))) TS_RawDataPart_free(uint32_t this_obj) {
35432         LDKRawDataPart this_obj_conv;
35433         this_obj_conv.inner = (void*)(this_obj & (~1));
35434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35436         RawDataPart_free(this_obj_conv);
35437 }
35438
35439 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
35440         LDKRawDataPart this_ptr_conv;
35441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35442         this_ptr_conv.is_owned = false;
35443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35444         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
35445         uint64_t ret_ref = 0;
35446         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35447         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35449         ret_ref = (uint64_t)ret_var.inner;
35450         if (ret_var.is_owned) {
35451                 ret_ref |= 1;
35452         }
35453         return ret_ref;
35454 }
35455
35456 void  __attribute__((visibility("default"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
35457         LDKRawDataPart this_ptr_conv;
35458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35459         this_ptr_conv.is_owned = false;
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35461         LDKPositiveTimestamp val_conv;
35462         val_conv.inner = (void*)(val & (~1));
35463         val_conv.is_owned = (val & 1) || (val == 0);
35464         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35465         val_conv = PositiveTimestamp_clone(&val_conv);
35466         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
35467 }
35468
35469 jboolean  __attribute__((visibility("default"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
35470         LDKRawDataPart a_conv;
35471         a_conv.inner = (void*)(a & (~1));
35472         a_conv.is_owned = false;
35473         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35474         LDKRawDataPart b_conv;
35475         b_conv.inner = (void*)(b & (~1));
35476         b_conv.is_owned = false;
35477         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35478         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
35479         return ret_val;
35480 }
35481
35482 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
35483         LDKRawDataPart ret_var = RawDataPart_clone(arg);
35484 uint64_t ret_ref = 0;
35485 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35486 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35487 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35488 ret_ref = (uint64_t)ret_var.inner;
35489 if (ret_var.is_owned) {
35490         ret_ref |= 1;
35491 }
35492         return ret_ref;
35493 }
35494 int64_t  __attribute__((visibility("default"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
35495         LDKRawDataPart arg_conv;
35496         arg_conv.inner = (void*)(arg & (~1));
35497         arg_conv.is_owned = false;
35498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35499         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
35500         return ret_val;
35501 }
35502
35503 uint32_t  __attribute__((visibility("default"))) TS_RawDataPart_clone(uint32_t orig) {
35504         LDKRawDataPart orig_conv;
35505         orig_conv.inner = (void*)(orig & (~1));
35506         orig_conv.is_owned = false;
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35508         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
35509         uint64_t ret_ref = 0;
35510         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35511         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35513         ret_ref = (uint64_t)ret_var.inner;
35514         if (ret_var.is_owned) {
35515                 ret_ref |= 1;
35516         }
35517         return ret_ref;
35518 }
35519
35520 void  __attribute__((visibility("default"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
35521         LDKPositiveTimestamp this_obj_conv;
35522         this_obj_conv.inner = (void*)(this_obj & (~1));
35523         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35525         PositiveTimestamp_free(this_obj_conv);
35526 }
35527
35528 jboolean  __attribute__((visibility("default"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
35529         LDKPositiveTimestamp a_conv;
35530         a_conv.inner = (void*)(a & (~1));
35531         a_conv.is_owned = false;
35532         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35533         LDKPositiveTimestamp b_conv;
35534         b_conv.inner = (void*)(b & (~1));
35535         b_conv.is_owned = false;
35536         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35537         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
35538         return ret_val;
35539 }
35540
35541 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
35542         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
35543 uint64_t ret_ref = 0;
35544 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35545 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35546 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35547 ret_ref = (uint64_t)ret_var.inner;
35548 if (ret_var.is_owned) {
35549         ret_ref |= 1;
35550 }
35551         return ret_ref;
35552 }
35553 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
35554         LDKPositiveTimestamp arg_conv;
35555         arg_conv.inner = (void*)(arg & (~1));
35556         arg_conv.is_owned = false;
35557         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35558         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
35559         return ret_val;
35560 }
35561
35562 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_clone(uint32_t orig) {
35563         LDKPositiveTimestamp orig_conv;
35564         orig_conv.inner = (void*)(orig & (~1));
35565         orig_conv.is_owned = false;
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35567         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
35568         uint64_t ret_ref = 0;
35569         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35570         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35572         ret_ref = (uint64_t)ret_var.inner;
35573         if (ret_var.is_owned) {
35574                 ret_ref |= 1;
35575         }
35576         return ret_ref;
35577 }
35578
35579 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_clone(uint32_t orig) {
35580         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
35581         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
35582         return ret_conv;
35583 }
35584
35585 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_milli() {
35586         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
35587         return ret_conv;
35588 }
35589
35590 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_micro() {
35591         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
35592         return ret_conv;
35593 }
35594
35595 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_nano() {
35596         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
35597         return ret_conv;
35598 }
35599
35600 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_pico() {
35601         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
35602         return ret_conv;
35603 }
35604
35605 jboolean  __attribute__((visibility("default"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
35606         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
35607         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
35608         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
35609         return ret_val;
35610 }
35611
35612 int64_t  __attribute__((visibility("default"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
35613         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
35614         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
35615         return ret_val;
35616 }
35617
35618 uint32_t  __attribute__((visibility("default"))) TS_Currency_clone(uint32_t orig) {
35619         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
35620         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
35621         return ret_conv;
35622 }
35623
35624 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin() {
35625         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
35626         return ret_conv;
35627 }
35628
35629 uint32_t  __attribute__((visibility("default"))) TS_Currency_bitcoin_testnet() {
35630         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
35631         return ret_conv;
35632 }
35633
35634 uint32_t  __attribute__((visibility("default"))) TS_Currency_regtest() {
35635         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
35636         return ret_conv;
35637 }
35638
35639 uint32_t  __attribute__((visibility("default"))) TS_Currency_simnet() {
35640         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
35641         return ret_conv;
35642 }
35643
35644 uint32_t  __attribute__((visibility("default"))) TS_Currency_signet() {
35645         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
35646         return ret_conv;
35647 }
35648
35649 int64_t  __attribute__((visibility("default"))) TS_Currency_hash(uint32_t o) {
35650         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
35651         int64_t ret_val = Currency_hash(o_conv);
35652         return ret_val;
35653 }
35654
35655 jboolean  __attribute__((visibility("default"))) TS_Currency_eq(uint32_t a, uint32_t b) {
35656         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
35657         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
35658         jboolean ret_val = Currency_eq(a_conv, b_conv);
35659         return ret_val;
35660 }
35661
35662 void  __attribute__((visibility("default"))) TS_Sha256_free(uint32_t this_obj) {
35663         LDKSha256 this_obj_conv;
35664         this_obj_conv.inner = (void*)(this_obj & (~1));
35665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35667         Sha256_free(this_obj_conv);
35668 }
35669
35670 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
35671         LDKSha256 ret_var = Sha256_clone(arg);
35672 uint64_t ret_ref = 0;
35673 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35674 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35675 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35676 ret_ref = (uint64_t)ret_var.inner;
35677 if (ret_var.is_owned) {
35678         ret_ref |= 1;
35679 }
35680         return ret_ref;
35681 }
35682 int64_t  __attribute__((visibility("default"))) TS_Sha256_clone_ptr(uint32_t arg) {
35683         LDKSha256 arg_conv;
35684         arg_conv.inner = (void*)(arg & (~1));
35685         arg_conv.is_owned = false;
35686         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35687         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
35688         return ret_val;
35689 }
35690
35691 uint32_t  __attribute__((visibility("default"))) TS_Sha256_clone(uint32_t orig) {
35692         LDKSha256 orig_conv;
35693         orig_conv.inner = (void*)(orig & (~1));
35694         orig_conv.is_owned = false;
35695         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35696         LDKSha256 ret_var = Sha256_clone(&orig_conv);
35697         uint64_t ret_ref = 0;
35698         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35699         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35701         ret_ref = (uint64_t)ret_var.inner;
35702         if (ret_var.is_owned) {
35703                 ret_ref |= 1;
35704         }
35705         return ret_ref;
35706 }
35707
35708 int64_t  __attribute__((visibility("default"))) TS_Sha256_hash(uint32_t o) {
35709         LDKSha256 o_conv;
35710         o_conv.inner = (void*)(o & (~1));
35711         o_conv.is_owned = false;
35712         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35713         int64_t ret_val = Sha256_hash(&o_conv);
35714         return ret_val;
35715 }
35716
35717 jboolean  __attribute__((visibility("default"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
35718         LDKSha256 a_conv;
35719         a_conv.inner = (void*)(a & (~1));
35720         a_conv.is_owned = false;
35721         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35722         LDKSha256 b_conv;
35723         b_conv.inner = (void*)(b & (~1));
35724         b_conv.is_owned = false;
35725         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35726         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
35727         return ret_val;
35728 }
35729
35730 void  __attribute__((visibility("default"))) TS_Description_free(uint32_t this_obj) {
35731         LDKDescription this_obj_conv;
35732         this_obj_conv.inner = (void*)(this_obj & (~1));
35733         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35735         Description_free(this_obj_conv);
35736 }
35737
35738 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
35739         LDKDescription ret_var = Description_clone(arg);
35740 uint64_t ret_ref = 0;
35741 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35742 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35743 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35744 ret_ref = (uint64_t)ret_var.inner;
35745 if (ret_var.is_owned) {
35746         ret_ref |= 1;
35747 }
35748         return ret_ref;
35749 }
35750 int64_t  __attribute__((visibility("default"))) TS_Description_clone_ptr(uint32_t arg) {
35751         LDKDescription arg_conv;
35752         arg_conv.inner = (void*)(arg & (~1));
35753         arg_conv.is_owned = false;
35754         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35755         int64_t ret_val = Description_clone_ptr(&arg_conv);
35756         return ret_val;
35757 }
35758
35759 uint32_t  __attribute__((visibility("default"))) TS_Description_clone(uint32_t orig) {
35760         LDKDescription orig_conv;
35761         orig_conv.inner = (void*)(orig & (~1));
35762         orig_conv.is_owned = false;
35763         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35764         LDKDescription ret_var = Description_clone(&orig_conv);
35765         uint64_t ret_ref = 0;
35766         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35767         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35769         ret_ref = (uint64_t)ret_var.inner;
35770         if (ret_var.is_owned) {
35771                 ret_ref |= 1;
35772         }
35773         return ret_ref;
35774 }
35775
35776 int64_t  __attribute__((visibility("default"))) TS_Description_hash(uint32_t o) {
35777         LDKDescription o_conv;
35778         o_conv.inner = (void*)(o & (~1));
35779         o_conv.is_owned = false;
35780         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35781         int64_t ret_val = Description_hash(&o_conv);
35782         return ret_val;
35783 }
35784
35785 jboolean  __attribute__((visibility("default"))) TS_Description_eq(uint32_t a, uint32_t b) {
35786         LDKDescription a_conv;
35787         a_conv.inner = (void*)(a & (~1));
35788         a_conv.is_owned = false;
35789         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35790         LDKDescription b_conv;
35791         b_conv.inner = (void*)(b & (~1));
35792         b_conv.is_owned = false;
35793         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35794         jboolean ret_val = Description_eq(&a_conv, &b_conv);
35795         return ret_val;
35796 }
35797
35798 void  __attribute__((visibility("default"))) TS_PayeePubKey_free(uint32_t this_obj) {
35799         LDKPayeePubKey this_obj_conv;
35800         this_obj_conv.inner = (void*)(this_obj & (~1));
35801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35803         PayeePubKey_free(this_obj_conv);
35804 }
35805
35806 int8_tArray  __attribute__((visibility("default"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
35807         LDKPayeePubKey this_ptr_conv;
35808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35809         this_ptr_conv.is_owned = false;
35810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35811         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
35812         memcpy((uint8_t*)(ret_arr + 4), PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
35813         return ret_arr;
35814 }
35815
35816 void  __attribute__((visibility("default"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
35817         LDKPayeePubKey this_ptr_conv;
35818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35819         this_ptr_conv.is_owned = false;
35820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35821         LDKPublicKey val_ref;
35822         CHECK(*((uint32_t*)val) == 33);
35823         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
35824         PayeePubKey_set_a(&this_ptr_conv, val_ref);
35825 }
35826
35827 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_new(int8_tArray a_arg) {
35828         LDKPublicKey a_arg_ref;
35829         CHECK(*((uint32_t*)a_arg) == 33);
35830         memcpy(a_arg_ref.compressed_form, (uint8_t*)(a_arg + 4), 33);
35831         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
35832         uint64_t ret_ref = 0;
35833         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35834         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35836         ret_ref = (uint64_t)ret_var.inner;
35837         if (ret_var.is_owned) {
35838                 ret_ref |= 1;
35839         }
35840         return ret_ref;
35841 }
35842
35843 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
35844         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
35845 uint64_t ret_ref = 0;
35846 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35847 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35848 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35849 ret_ref = (uint64_t)ret_var.inner;
35850 if (ret_var.is_owned) {
35851         ret_ref |= 1;
35852 }
35853         return ret_ref;
35854 }
35855 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
35856         LDKPayeePubKey arg_conv;
35857         arg_conv.inner = (void*)(arg & (~1));
35858         arg_conv.is_owned = false;
35859         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35860         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
35861         return ret_val;
35862 }
35863
35864 uint32_t  __attribute__((visibility("default"))) TS_PayeePubKey_clone(uint32_t orig) {
35865         LDKPayeePubKey orig_conv;
35866         orig_conv.inner = (void*)(orig & (~1));
35867         orig_conv.is_owned = false;
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35869         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
35870         uint64_t ret_ref = 0;
35871         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35872         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35874         ret_ref = (uint64_t)ret_var.inner;
35875         if (ret_var.is_owned) {
35876                 ret_ref |= 1;
35877         }
35878         return ret_ref;
35879 }
35880
35881 int64_t  __attribute__((visibility("default"))) TS_PayeePubKey_hash(uint32_t o) {
35882         LDKPayeePubKey o_conv;
35883         o_conv.inner = (void*)(o & (~1));
35884         o_conv.is_owned = false;
35885         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35886         int64_t ret_val = PayeePubKey_hash(&o_conv);
35887         return ret_val;
35888 }
35889
35890 jboolean  __attribute__((visibility("default"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
35891         LDKPayeePubKey a_conv;
35892         a_conv.inner = (void*)(a & (~1));
35893         a_conv.is_owned = false;
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35895         LDKPayeePubKey b_conv;
35896         b_conv.inner = (void*)(b & (~1));
35897         b_conv.is_owned = false;
35898         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35899         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
35900         return ret_val;
35901 }
35902
35903 void  __attribute__((visibility("default"))) TS_ExpiryTime_free(uint32_t this_obj) {
35904         LDKExpiryTime this_obj_conv;
35905         this_obj_conv.inner = (void*)(this_obj & (~1));
35906         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35908         ExpiryTime_free(this_obj_conv);
35909 }
35910
35911 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
35912         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
35913 uint64_t ret_ref = 0;
35914 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35915 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35916 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35917 ret_ref = (uint64_t)ret_var.inner;
35918 if (ret_var.is_owned) {
35919         ret_ref |= 1;
35920 }
35921         return ret_ref;
35922 }
35923 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
35924         LDKExpiryTime arg_conv;
35925         arg_conv.inner = (void*)(arg & (~1));
35926         arg_conv.is_owned = false;
35927         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35928         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
35929         return ret_val;
35930 }
35931
35932 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_clone(uint32_t orig) {
35933         LDKExpiryTime orig_conv;
35934         orig_conv.inner = (void*)(orig & (~1));
35935         orig_conv.is_owned = false;
35936         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35937         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
35938         uint64_t ret_ref = 0;
35939         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35940         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35942         ret_ref = (uint64_t)ret_var.inner;
35943         if (ret_var.is_owned) {
35944                 ret_ref |= 1;
35945         }
35946         return ret_ref;
35947 }
35948
35949 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_hash(uint32_t o) {
35950         LDKExpiryTime o_conv;
35951         o_conv.inner = (void*)(o & (~1));
35952         o_conv.is_owned = false;
35953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35954         int64_t ret_val = ExpiryTime_hash(&o_conv);
35955         return ret_val;
35956 }
35957
35958 jboolean  __attribute__((visibility("default"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
35959         LDKExpiryTime a_conv;
35960         a_conv.inner = (void*)(a & (~1));
35961         a_conv.is_owned = false;
35962         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35963         LDKExpiryTime b_conv;
35964         b_conv.inner = (void*)(b & (~1));
35965         b_conv.is_owned = false;
35966         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35967         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
35968         return ret_val;
35969 }
35970
35971 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
35972         LDKMinFinalCltvExpiry this_obj_conv;
35973         this_obj_conv.inner = (void*)(this_obj & (~1));
35974         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35976         MinFinalCltvExpiry_free(this_obj_conv);
35977 }
35978
35979 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
35980         LDKMinFinalCltvExpiry this_ptr_conv;
35981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35982         this_ptr_conv.is_owned = false;
35983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35984         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
35985         return ret_val;
35986 }
35987
35988 void  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
35989         LDKMinFinalCltvExpiry this_ptr_conv;
35990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35991         this_ptr_conv.is_owned = false;
35992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35993         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
35994 }
35995
35996 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
35997         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
35998         uint64_t ret_ref = 0;
35999         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36000         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36002         ret_ref = (uint64_t)ret_var.inner;
36003         if (ret_var.is_owned) {
36004                 ret_ref |= 1;
36005         }
36006         return ret_ref;
36007 }
36008
36009 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
36010         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
36011 uint64_t ret_ref = 0;
36012 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36013 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36014 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36015 ret_ref = (uint64_t)ret_var.inner;
36016 if (ret_var.is_owned) {
36017         ret_ref |= 1;
36018 }
36019         return ret_ref;
36020 }
36021 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
36022         LDKMinFinalCltvExpiry arg_conv;
36023         arg_conv.inner = (void*)(arg & (~1));
36024         arg_conv.is_owned = false;
36025         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36026         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
36027         return ret_val;
36028 }
36029
36030 uint32_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
36031         LDKMinFinalCltvExpiry orig_conv;
36032         orig_conv.inner = (void*)(orig & (~1));
36033         orig_conv.is_owned = false;
36034         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36035         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
36036         uint64_t ret_ref = 0;
36037         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36038         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36040         ret_ref = (uint64_t)ret_var.inner;
36041         if (ret_var.is_owned) {
36042                 ret_ref |= 1;
36043         }
36044         return ret_ref;
36045 }
36046
36047 int64_t  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
36048         LDKMinFinalCltvExpiry o_conv;
36049         o_conv.inner = (void*)(o & (~1));
36050         o_conv.is_owned = false;
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36052         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
36053         return ret_val;
36054 }
36055
36056 jboolean  __attribute__((visibility("default"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
36057         LDKMinFinalCltvExpiry a_conv;
36058         a_conv.inner = (void*)(a & (~1));
36059         a_conv.is_owned = false;
36060         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36061         LDKMinFinalCltvExpiry b_conv;
36062         b_conv.inner = (void*)(b & (~1));
36063         b_conv.is_owned = false;
36064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36065         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
36066         return ret_val;
36067 }
36068
36069 void  __attribute__((visibility("default"))) TS_Fallback_free(uint32_t this_ptr) {
36070         if ((this_ptr & 1) != 0) return;
36071         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
36072         CHECK_ACCESS(this_ptr_ptr);
36073         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
36074         FREE((void*)this_ptr);
36075         Fallback_free(this_ptr_conv);
36076 }
36077
36078 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
36079         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
36080         *ret_copy = Fallback_clone(arg);
36081 uint64_t ret_ref = (uint64_t)ret_copy;
36082         return ret_ref;
36083 }
36084 int64_t  __attribute__((visibility("default"))) TS_Fallback_clone_ptr(uint32_t arg) {
36085         LDKFallback* arg_conv = (LDKFallback*)arg;
36086         int64_t ret_val = Fallback_clone_ptr(arg_conv);
36087         return ret_val;
36088 }
36089
36090 uint32_t  __attribute__((visibility("default"))) TS_Fallback_clone(uint32_t orig) {
36091         LDKFallback* orig_conv = (LDKFallback*)orig;
36092         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
36093         *ret_copy = Fallback_clone(orig_conv);
36094         uint64_t ret_ref = (uint64_t)ret_copy;
36095         return ret_ref;
36096 }
36097
36098 uint32_t  __attribute__((visibility("default"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
36099         
36100         LDKCVec_u8Z program_ref;
36101         program_ref.datalen = *((uint32_t*)program);
36102         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
36103         memcpy(program_ref.data, (uint8_t*)(program + 4), program_ref.datalen);
36104         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
36105         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
36106         uint64_t ret_ref = (uint64_t)ret_copy;
36107         return ret_ref;
36108 }
36109
36110 uint32_t  __attribute__((visibility("default"))) TS_Fallback_pub_key_hash(int8_tArray a) {
36111         LDKTwentyBytes a_ref;
36112         CHECK(*((uint32_t*)a) == 20);
36113         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
36114         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
36115         *ret_copy = Fallback_pub_key_hash(a_ref);
36116         uint64_t ret_ref = (uint64_t)ret_copy;
36117         return ret_ref;
36118 }
36119
36120 uint32_t  __attribute__((visibility("default"))) TS_Fallback_script_hash(int8_tArray a) {
36121         LDKTwentyBytes a_ref;
36122         CHECK(*((uint32_t*)a) == 20);
36123         memcpy(a_ref.data, (uint8_t*)(a + 4), 20);
36124         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
36125         *ret_copy = Fallback_script_hash(a_ref);
36126         uint64_t ret_ref = (uint64_t)ret_copy;
36127         return ret_ref;
36128 }
36129
36130 int64_t  __attribute__((visibility("default"))) TS_Fallback_hash(uint32_t o) {
36131         LDKFallback* o_conv = (LDKFallback*)o;
36132         int64_t ret_val = Fallback_hash(o_conv);
36133         return ret_val;
36134 }
36135
36136 jboolean  __attribute__((visibility("default"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
36137         LDKFallback* a_conv = (LDKFallback*)a;
36138         LDKFallback* b_conv = (LDKFallback*)b;
36139         jboolean ret_val = Fallback_eq(a_conv, b_conv);
36140         return ret_val;
36141 }
36142
36143 void  __attribute__((visibility("default"))) TS_InvoiceSignature_free(uint32_t this_obj) {
36144         LDKInvoiceSignature this_obj_conv;
36145         this_obj_conv.inner = (void*)(this_obj & (~1));
36146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36148         InvoiceSignature_free(this_obj_conv);
36149 }
36150
36151 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
36152         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
36153 uint64_t ret_ref = 0;
36154 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36155 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36156 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36157 ret_ref = (uint64_t)ret_var.inner;
36158 if (ret_var.is_owned) {
36159         ret_ref |= 1;
36160 }
36161         return ret_ref;
36162 }
36163 int64_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
36164         LDKInvoiceSignature arg_conv;
36165         arg_conv.inner = (void*)(arg & (~1));
36166         arg_conv.is_owned = false;
36167         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36168         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
36169         return ret_val;
36170 }
36171
36172 uint32_t  __attribute__((visibility("default"))) TS_InvoiceSignature_clone(uint32_t orig) {
36173         LDKInvoiceSignature orig_conv;
36174         orig_conv.inner = (void*)(orig & (~1));
36175         orig_conv.is_owned = false;
36176         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36177         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
36178         uint64_t ret_ref = 0;
36179         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36180         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36182         ret_ref = (uint64_t)ret_var.inner;
36183         if (ret_var.is_owned) {
36184                 ret_ref |= 1;
36185         }
36186         return ret_ref;
36187 }
36188
36189 jboolean  __attribute__((visibility("default"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
36190         LDKInvoiceSignature a_conv;
36191         a_conv.inner = (void*)(a & (~1));
36192         a_conv.is_owned = false;
36193         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36194         LDKInvoiceSignature b_conv;
36195         b_conv.inner = (void*)(b & (~1));
36196         b_conv.is_owned = false;
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36198         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
36199         return ret_val;
36200 }
36201
36202 void  __attribute__((visibility("default"))) TS_PrivateRoute_free(uint32_t this_obj) {
36203         LDKPrivateRoute this_obj_conv;
36204         this_obj_conv.inner = (void*)(this_obj & (~1));
36205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36207         PrivateRoute_free(this_obj_conv);
36208 }
36209
36210 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
36211         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
36212 uint64_t ret_ref = 0;
36213 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36214 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36215 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36216 ret_ref = (uint64_t)ret_var.inner;
36217 if (ret_var.is_owned) {
36218         ret_ref |= 1;
36219 }
36220         return ret_ref;
36221 }
36222 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
36223         LDKPrivateRoute arg_conv;
36224         arg_conv.inner = (void*)(arg & (~1));
36225         arg_conv.is_owned = false;
36226         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36227         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
36228         return ret_val;
36229 }
36230
36231 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_clone(uint32_t orig) {
36232         LDKPrivateRoute orig_conv;
36233         orig_conv.inner = (void*)(orig & (~1));
36234         orig_conv.is_owned = false;
36235         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36236         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
36237         uint64_t ret_ref = 0;
36238         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36239         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36241         ret_ref = (uint64_t)ret_var.inner;
36242         if (ret_var.is_owned) {
36243                 ret_ref |= 1;
36244         }
36245         return ret_ref;
36246 }
36247
36248 int64_t  __attribute__((visibility("default"))) TS_PrivateRoute_hash(uint32_t o) {
36249         LDKPrivateRoute o_conv;
36250         o_conv.inner = (void*)(o & (~1));
36251         o_conv.is_owned = false;
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36253         int64_t ret_val = PrivateRoute_hash(&o_conv);
36254         return ret_val;
36255 }
36256
36257 jboolean  __attribute__((visibility("default"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
36258         LDKPrivateRoute a_conv;
36259         a_conv.inner = (void*)(a & (~1));
36260         a_conv.is_owned = false;
36261         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36262         LDKPrivateRoute b_conv;
36263         b_conv.inner = (void*)(b & (~1));
36264         b_conv.is_owned = false;
36265         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36266         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
36267         return ret_val;
36268 }
36269
36270 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
36271         LDKSignedRawInvoice this_arg_conv;
36272         this_arg_conv.inner = (void*)(this_arg & (~1));
36273         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36275         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
36276         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
36277         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
36278         return ((uint64_t)ret_conv);
36279 }
36280
36281 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
36282         LDKSignedRawInvoice this_arg_conv;
36283         this_arg_conv.inner = (void*)(this_arg & (~1));
36284         this_arg_conv.is_owned = false;
36285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36286         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
36287         uint64_t ret_ref = 0;
36288         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36289         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36291         ret_ref = (uint64_t)ret_var.inner;
36292         if (ret_var.is_owned) {
36293                 ret_ref |= 1;
36294         }
36295         return ret_ref;
36296 }
36297
36298 int8_tArray  __attribute__((visibility("default"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
36299         LDKSignedRawInvoice this_arg_conv;
36300         this_arg_conv.inner = (void*)(this_arg & (~1));
36301         this_arg_conv.is_owned = false;
36302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36303         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
36304         memcpy((uint8_t*)(ret_arr + 4), *SignedRawInvoice_hash(&this_arg_conv), 32);
36305         return ret_arr;
36306 }
36307
36308 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
36309         LDKSignedRawInvoice this_arg_conv;
36310         this_arg_conv.inner = (void*)(this_arg & (~1));
36311         this_arg_conv.is_owned = false;
36312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36313         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
36314         uint64_t ret_ref = 0;
36315         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36316         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36318         ret_ref = (uint64_t)ret_var.inner;
36319         if (ret_var.is_owned) {
36320                 ret_ref |= 1;
36321         }
36322         return ret_ref;
36323 }
36324
36325 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
36326         LDKSignedRawInvoice this_arg_conv;
36327         this_arg_conv.inner = (void*)(this_arg & (~1));
36328         this_arg_conv.is_owned = false;
36329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36330         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
36331         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
36332         return (uint64_t)ret_conv;
36333 }
36334
36335 jboolean  __attribute__((visibility("default"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
36336         LDKSignedRawInvoice this_arg_conv;
36337         this_arg_conv.inner = (void*)(this_arg & (~1));
36338         this_arg_conv.is_owned = false;
36339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36340         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
36341         return ret_val;
36342 }
36343
36344 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_hash(uint32_t this_arg) {
36345         LDKRawInvoice this_arg_conv;
36346         this_arg_conv.inner = (void*)(this_arg & (~1));
36347         this_arg_conv.is_owned = false;
36348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36349         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
36350         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_hash(&this_arg_conv).data, 32);
36351         return ret_arr;
36352 }
36353
36354 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
36355         LDKRawInvoice this_arg_conv;
36356         this_arg_conv.inner = (void*)(this_arg & (~1));
36357         this_arg_conv.is_owned = false;
36358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36359         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
36360         uint64_t ret_ref = 0;
36361         if ((uint64_t)ret_var.inner > 4096) {
36362                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36363                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36365                 ret_ref = (uint64_t)ret_var.inner;
36366                 if (ret_var.is_owned) {
36367                         ret_ref |= 1;
36368                 }
36369         }
36370         return ret_ref;
36371 }
36372
36373 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description(uint32_t this_arg) {
36374         LDKRawInvoice this_arg_conv;
36375         this_arg_conv.inner = (void*)(this_arg & (~1));
36376         this_arg_conv.is_owned = false;
36377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36378         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
36379         uint64_t ret_ref = 0;
36380         if ((uint64_t)ret_var.inner > 4096) {
36381                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36382                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36384                 ret_ref = (uint64_t)ret_var.inner;
36385                 if (ret_var.is_owned) {
36386                         ret_ref |= 1;
36387                 }
36388         }
36389         return ret_ref;
36390 }
36391
36392 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
36393         LDKRawInvoice this_arg_conv;
36394         this_arg_conv.inner = (void*)(this_arg & (~1));
36395         this_arg_conv.is_owned = false;
36396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36397         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
36398         uint64_t ret_ref = 0;
36399         if ((uint64_t)ret_var.inner > 4096) {
36400                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36401                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36403                 ret_ref = (uint64_t)ret_var.inner;
36404                 if (ret_var.is_owned) {
36405                         ret_ref |= 1;
36406                 }
36407         }
36408         return ret_ref;
36409 }
36410
36411 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
36412         LDKRawInvoice this_arg_conv;
36413         this_arg_conv.inner = (void*)(this_arg & (~1));
36414         this_arg_conv.is_owned = false;
36415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36416         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
36417         uint64_t ret_ref = 0;
36418         if ((uint64_t)ret_var.inner > 4096) {
36419                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36420                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36422                 ret_ref = (uint64_t)ret_var.inner;
36423                 if (ret_var.is_owned) {
36424                         ret_ref |= 1;
36425                 }
36426         }
36427         return ret_ref;
36428 }
36429
36430 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
36431         LDKRawInvoice this_arg_conv;
36432         this_arg_conv.inner = (void*)(this_arg & (~1));
36433         this_arg_conv.is_owned = false;
36434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36435         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
36436         uint64_t ret_ref = 0;
36437         if ((uint64_t)ret_var.inner > 4096) {
36438                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36439                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36441                 ret_ref = (uint64_t)ret_var.inner;
36442                 if (ret_var.is_owned) {
36443                         ret_ref |= 1;
36444                 }
36445         }
36446         return ret_ref;
36447 }
36448
36449 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
36450         LDKRawInvoice this_arg_conv;
36451         this_arg_conv.inner = (void*)(this_arg & (~1));
36452         this_arg_conv.is_owned = false;
36453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36454         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
36455         uint64_t ret_ref = 0;
36456         if ((uint64_t)ret_var.inner > 4096) {
36457                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36458                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36460                 ret_ref = (uint64_t)ret_var.inner;
36461                 if (ret_var.is_owned) {
36462                         ret_ref |= 1;
36463                 }
36464         }
36465         return ret_ref;
36466 }
36467
36468 int8_tArray  __attribute__((visibility("default"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
36469         LDKRawInvoice this_arg_conv;
36470         this_arg_conv.inner = (void*)(this_arg & (~1));
36471         this_arg_conv.is_owned = false;
36472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36473         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
36474         memcpy((uint8_t*)(ret_arr + 4), RawInvoice_payment_secret(&this_arg_conv).data, 32);
36475         return ret_arr;
36476 }
36477
36478 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_features(uint32_t this_arg) {
36479         LDKRawInvoice this_arg_conv;
36480         this_arg_conv.inner = (void*)(this_arg & (~1));
36481         this_arg_conv.is_owned = false;
36482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36483         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
36484         uint64_t ret_ref = 0;
36485         if ((uint64_t)ret_var.inner > 4096) {
36486                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36487                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36489                 ret_ref = (uint64_t)ret_var.inner;
36490                 if (ret_var.is_owned) {
36491                         ret_ref |= 1;
36492                 }
36493         }
36494         return ret_ref;
36495 }
36496
36497 uint32_tArray  __attribute__((visibility("default"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
36498         LDKRawInvoice this_arg_conv;
36499         this_arg_conv.inner = (void*)(this_arg & (~1));
36500         this_arg_conv.is_owned = false;
36501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36502         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
36503         uint32_tArray ret_arr = NULL;
36504         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
36505         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
36506         for (size_t o = 0; o < ret_var.datalen; o++) {
36507                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
36508                 uint64_t ret_conv_14_ref = 0;
36509                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36510                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36511                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
36512                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
36513                 if (ret_conv_14_var.is_owned) {
36514                         ret_conv_14_ref |= 1;
36515                 }
36516                 ret_arr_ptr[o] = ret_conv_14_ref;
36517         }
36518         
36519         FREE(ret_var.data);
36520         return ret_arr;
36521 }
36522
36523 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
36524         LDKRawInvoice this_arg_conv;
36525         this_arg_conv.inner = (void*)(this_arg & (~1));
36526         this_arg_conv.is_owned = false;
36527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36528         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36529         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
36530         uint64_t ret_ref = (uint64_t)ret_copy;
36531         return ret_ref;
36532 }
36533
36534 uint32_t  __attribute__((visibility("default"))) TS_RawInvoice_currency(uint32_t this_arg) {
36535         LDKRawInvoice this_arg_conv;
36536         this_arg_conv.inner = (void*)(this_arg & (~1));
36537         this_arg_conv.is_owned = false;
36538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36539         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
36540         return ret_conv;
36541 }
36542
36543 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
36544         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
36545         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
36546         return (uint64_t)ret_conv;
36547 }
36548
36549 uint32_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_from_system_time(int64_t time) {
36550         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
36551         *ret_conv = PositiveTimestamp_from_system_time(time);
36552         return (uint64_t)ret_conv;
36553 }
36554
36555 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
36556         LDKPositiveTimestamp this_arg_conv;
36557         this_arg_conv.inner = (void*)(this_arg & (~1));
36558         this_arg_conv.is_owned = false;
36559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36560         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
36561         return ret_val;
36562 }
36563
36564 int64_t  __attribute__((visibility("default"))) TS_PositiveTimestamp_as_time(uint32_t this_arg) {
36565         LDKPositiveTimestamp this_arg_conv;
36566         this_arg_conv.inner = (void*)(this_arg & (~1));
36567         this_arg_conv.is_owned = false;
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36569         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
36570         return ret_val;
36571 }
36572
36573 uint32_t  __attribute__((visibility("default"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
36574         LDKInvoice this_arg_conv;
36575         this_arg_conv.inner = (void*)(this_arg & (~1));
36576         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36578         this_arg_conv = Invoice_clone(&this_arg_conv);
36579         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
36580         uint64_t ret_ref = 0;
36581         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36582         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36584         ret_ref = (uint64_t)ret_var.inner;
36585         if (ret_var.is_owned) {
36586                 ret_ref |= 1;
36587         }
36588         return ret_ref;
36589 }
36590
36591 uint32_t  __attribute__((visibility("default"))) TS_Invoice_check_signature(uint32_t this_arg) {
36592         LDKInvoice this_arg_conv;
36593         this_arg_conv.inner = (void*)(this_arg & (~1));
36594         this_arg_conv.is_owned = false;
36595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36596         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
36597         *ret_conv = Invoice_check_signature(&this_arg_conv);
36598         return (uint64_t)ret_conv;
36599 }
36600
36601 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
36602         LDKSignedRawInvoice signed_invoice_conv;
36603         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
36604         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
36605         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
36606         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
36607         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
36608         *ret_conv = Invoice_from_signed(signed_invoice_conv);
36609         return (uint64_t)ret_conv;
36610 }
36611
36612 int64_t  __attribute__((visibility("default"))) TS_Invoice_timestamp(uint32_t this_arg) {
36613         LDKInvoice this_arg_conv;
36614         this_arg_conv.inner = (void*)(this_arg & (~1));
36615         this_arg_conv.is_owned = false;
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36617         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
36618         return ret_val;
36619 }
36620
36621 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_hash(uint32_t this_arg) {
36622         LDKInvoice this_arg_conv;
36623         this_arg_conv.inner = (void*)(this_arg & (~1));
36624         this_arg_conv.is_owned = false;
36625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36626         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
36627         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_hash(&this_arg_conv), 32);
36628         return ret_arr;
36629 }
36630
36631 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
36632         LDKInvoice this_arg_conv;
36633         this_arg_conv.inner = (void*)(this_arg & (~1));
36634         this_arg_conv.is_owned = false;
36635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36636         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
36637         memcpy((uint8_t*)(ret_arr + 4), Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
36638         return ret_arr;
36639 }
36640
36641 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_payment_secret(uint32_t this_arg) {
36642         LDKInvoice this_arg_conv;
36643         this_arg_conv.inner = (void*)(this_arg & (~1));
36644         this_arg_conv.is_owned = false;
36645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36646         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
36647         memcpy((uint8_t*)(ret_arr + 4), *Invoice_payment_secret(&this_arg_conv), 32);
36648         return ret_arr;
36649 }
36650
36651 uint32_t  __attribute__((visibility("default"))) TS_Invoice_features(uint32_t this_arg) {
36652         LDKInvoice this_arg_conv;
36653         this_arg_conv.inner = (void*)(this_arg & (~1));
36654         this_arg_conv.is_owned = false;
36655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36656         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
36657         uint64_t ret_ref = 0;
36658         if ((uint64_t)ret_var.inner > 4096) {
36659                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36660                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36662                 ret_ref = (uint64_t)ret_var.inner;
36663                 if (ret_var.is_owned) {
36664                         ret_ref |= 1;
36665                 }
36666         }
36667         return ret_ref;
36668 }
36669
36670 int8_tArray  __attribute__((visibility("default"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
36671         LDKInvoice this_arg_conv;
36672         this_arg_conv.inner = (void*)(this_arg & (~1));
36673         this_arg_conv.is_owned = false;
36674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36675         int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
36676         memcpy((uint8_t*)(ret_arr + 4), Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
36677         return ret_arr;
36678 }
36679
36680 int64_t  __attribute__((visibility("default"))) TS_Invoice_expiry_time(uint32_t this_arg) {
36681         LDKInvoice this_arg_conv;
36682         this_arg_conv.inner = (void*)(this_arg & (~1));
36683         this_arg_conv.is_owned = false;
36684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36685         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
36686         return ret_val;
36687 }
36688
36689 jboolean  __attribute__((visibility("default"))) TS_Invoice_is_expired(uint32_t this_arg) {
36690         LDKInvoice this_arg_conv;
36691         this_arg_conv.inner = (void*)(this_arg & (~1));
36692         this_arg_conv.is_owned = false;
36693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36694         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
36695         return ret_val;
36696 }
36697
36698 int64_t  __attribute__((visibility("default"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
36699         LDKInvoice this_arg_conv;
36700         this_arg_conv.inner = (void*)(this_arg & (~1));
36701         this_arg_conv.is_owned = false;
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36703         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
36704         return ret_val;
36705 }
36706
36707 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_private_routes(uint32_t this_arg) {
36708         LDKInvoice this_arg_conv;
36709         this_arg_conv.inner = (void*)(this_arg & (~1));
36710         this_arg_conv.is_owned = false;
36711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36712         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
36713         uint32_tArray ret_arr = NULL;
36714         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
36715         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
36716         for (size_t o = 0; o < ret_var.datalen; o++) {
36717                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
36718                 uint64_t ret_conv_14_ref = 0;
36719                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36720                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36721                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
36722                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
36723                 if (ret_conv_14_var.is_owned) {
36724                         ret_conv_14_ref |= 1;
36725                 }
36726                 ret_arr_ptr[o] = ret_conv_14_ref;
36727         }
36728         
36729         FREE(ret_var.data);
36730         return ret_arr;
36731 }
36732
36733 uint32_tArray  __attribute__((visibility("default"))) TS_Invoice_route_hints(uint32_t this_arg) {
36734         LDKInvoice this_arg_conv;
36735         this_arg_conv.inner = (void*)(this_arg & (~1));
36736         this_arg_conv.is_owned = false;
36737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36738         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
36739         uint32_tArray ret_arr = NULL;
36740         ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
36741         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
36742         for (size_t l = 0; l < ret_var.datalen; l++) {
36743                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
36744                 uint64_t ret_conv_11_ref = 0;
36745                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36746                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36747                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
36748                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
36749                 if (ret_conv_11_var.is_owned) {
36750                         ret_conv_11_ref |= 1;
36751                 }
36752                 ret_arr_ptr[l] = ret_conv_11_ref;
36753         }
36754         
36755         FREE(ret_var.data);
36756         return ret_arr;
36757 }
36758
36759 uint32_t  __attribute__((visibility("default"))) TS_Invoice_currency(uint32_t this_arg) {
36760         LDKInvoice this_arg_conv;
36761         this_arg_conv.inner = (void*)(this_arg & (~1));
36762         this_arg_conv.is_owned = false;
36763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36764         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
36765         return ret_conv;
36766 }
36767
36768 uint32_t  __attribute__((visibility("default"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
36769         LDKInvoice this_arg_conv;
36770         this_arg_conv.inner = (void*)(this_arg & (~1));
36771         this_arg_conv.is_owned = false;
36772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36773         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36774         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
36775         uint64_t ret_ref = (uint64_t)ret_copy;
36776         return ret_ref;
36777 }
36778
36779 uint32_t  __attribute__((visibility("default"))) TS_Description_new(jstring description) {
36780         LDKStr description_conv = str_ref_to_owned_c(description);
36781         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
36782         *ret_conv = Description_new(description_conv);
36783         return (uint64_t)ret_conv;
36784 }
36785
36786 jstring  __attribute__((visibility("default"))) TS_Description_into_inner(uint32_t this_arg) {
36787         LDKDescription this_arg_conv;
36788         this_arg_conv.inner = (void*)(this_arg & (~1));
36789         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36791         this_arg_conv = Description_clone(&this_arg_conv);
36792         LDKStr ret_str = Description_into_inner(this_arg_conv);
36793         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36794         Str_free(ret_str);
36795         return ret_conv;
36796 }
36797
36798 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
36799         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
36800         *ret_conv = ExpiryTime_from_seconds(seconds);
36801         return (uint64_t)ret_conv;
36802 }
36803
36804 uint32_t  __attribute__((visibility("default"))) TS_ExpiryTime_from_duration(int64_t duration) {
36805         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
36806         *ret_conv = ExpiryTime_from_duration(duration);
36807         return (uint64_t)ret_conv;
36808 }
36809
36810 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
36811         LDKExpiryTime this_arg_conv;
36812         this_arg_conv.inner = (void*)(this_arg & (~1));
36813         this_arg_conv.is_owned = false;
36814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36815         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
36816         return ret_val;
36817 }
36818
36819 int64_t  __attribute__((visibility("default"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
36820         LDKExpiryTime this_arg_conv;
36821         this_arg_conv.inner = (void*)(this_arg & (~1));
36822         this_arg_conv.is_owned = false;
36823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36824         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
36825         return ret_val;
36826 }
36827
36828 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_new(uint32_t hops) {
36829         LDKRouteHint hops_conv;
36830         hops_conv.inner = (void*)(hops & (~1));
36831         hops_conv.is_owned = (hops & 1) || (hops == 0);
36832         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
36833         hops_conv = RouteHint_clone(&hops_conv);
36834         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
36835         *ret_conv = PrivateRoute_new(hops_conv);
36836         return (uint64_t)ret_conv;
36837 }
36838
36839 uint32_t  __attribute__((visibility("default"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
36840         LDKPrivateRoute this_arg_conv;
36841         this_arg_conv.inner = (void*)(this_arg & (~1));
36842         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
36843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36844         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
36845         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
36846         uint64_t ret_ref = 0;
36847         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36848         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36850         ret_ref = (uint64_t)ret_var.inner;
36851         if (ret_var.is_owned) {
36852                 ret_ref |= 1;
36853         }
36854         return ret_ref;
36855 }
36856
36857 uint32_t  __attribute__((visibility("default"))) TS_CreationError_clone(uint32_t orig) {
36858         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
36859         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
36860         return ret_conv;
36861 }
36862
36863 uint32_t  __attribute__((visibility("default"))) TS_CreationError_description_too_long() {
36864         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
36865         return ret_conv;
36866 }
36867
36868 uint32_t  __attribute__((visibility("default"))) TS_CreationError_route_too_long() {
36869         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
36870         return ret_conv;
36871 }
36872
36873 uint32_t  __attribute__((visibility("default"))) TS_CreationError_timestamp_out_of_bounds() {
36874         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
36875         return ret_conv;
36876 }
36877
36878 uint32_t  __attribute__((visibility("default"))) TS_CreationError_expiry_time_out_of_bounds() {
36879         uint32_t ret_conv = LDKCreationError_to_js(CreationError_expiry_time_out_of_bounds());
36880         return ret_conv;
36881 }
36882
36883 uint32_t  __attribute__((visibility("default"))) TS_CreationError_invalid_amount() {
36884         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
36885         return ret_conv;
36886 }
36887
36888 jboolean  __attribute__((visibility("default"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
36889         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
36890         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
36891         jboolean ret_val = CreationError_eq(a_conv, b_conv);
36892         return ret_val;
36893 }
36894
36895 jstring  __attribute__((visibility("default"))) TS_CreationError_to_str(uint32_t o) {
36896         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
36897         LDKStr ret_str = CreationError_to_str(o_conv);
36898         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36899         Str_free(ret_str);
36900         return ret_conv;
36901 }
36902
36903 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_clone(uint32_t orig) {
36904         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
36905         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
36906         return ret_conv;
36907 }
36908
36909 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_hash() {
36910         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
36911         return ret_conv;
36912 }
36913
36914 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_hashes() {
36915         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
36916         return ret_conv;
36917 }
36918
36919 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_description() {
36920         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
36921         return ret_conv;
36922 }
36923
36924 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_descriptions() {
36925         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
36926         return ret_conv;
36927 }
36928
36929 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_no_payment_secret() {
36930         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
36931         return ret_conv;
36932 }
36933
36934 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_multiple_payment_secrets() {
36935         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
36936         return ret_conv;
36937 }
36938
36939 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_features() {
36940         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
36941         return ret_conv;
36942 }
36943
36944 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_recovery_id() {
36945         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
36946         return ret_conv;
36947 }
36948
36949 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_invalid_signature() {
36950         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
36951         return ret_conv;
36952 }
36953
36954 uint32_t  __attribute__((visibility("default"))) TS_SemanticError_imprecise_amount() {
36955         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
36956         return ret_conv;
36957 }
36958
36959 jboolean  __attribute__((visibility("default"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
36960         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
36961         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
36962         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
36963         return ret_val;
36964 }
36965
36966 jstring  __attribute__((visibility("default"))) TS_SemanticError_to_str(uint32_t o) {
36967         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
36968         LDKStr ret_str = SemanticError_to_str(o_conv);
36969         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
36970         Str_free(ret_str);
36971         return ret_conv;
36972 }
36973
36974 void  __attribute__((visibility("default"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
36975         if ((this_ptr & 1) != 0) return;
36976         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
36977         CHECK_ACCESS(this_ptr_ptr);
36978         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
36979         FREE((void*)this_ptr);
36980         SignOrCreationError_free(this_ptr_conv);
36981 }
36982
36983 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
36984         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
36985         *ret_copy = SignOrCreationError_clone(arg);
36986 uint64_t ret_ref = (uint64_t)ret_copy;
36987         return ret_ref;
36988 }
36989 int64_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
36990         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
36991         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
36992         return ret_val;
36993 }
36994
36995 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_clone(uint32_t orig) {
36996         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
36997         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
36998         *ret_copy = SignOrCreationError_clone(orig_conv);
36999         uint64_t ret_ref = (uint64_t)ret_copy;
37000         return ret_ref;
37001 }
37002
37003 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_sign_error() {
37004         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
37005         *ret_copy = SignOrCreationError_sign_error();
37006         uint64_t ret_ref = (uint64_t)ret_copy;
37007         return ret_ref;
37008 }
37009
37010 uint32_t  __attribute__((visibility("default"))) TS_SignOrCreationError_creation_error(uint32_t a) {
37011         LDKCreationError a_conv = LDKCreationError_from_js(a);
37012         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
37013         *ret_copy = SignOrCreationError_creation_error(a_conv);
37014         uint64_t ret_ref = (uint64_t)ret_copy;
37015         return ret_ref;
37016 }
37017
37018 jboolean  __attribute__((visibility("default"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
37019         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
37020         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
37021         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
37022         return ret_val;
37023 }
37024
37025 jstring  __attribute__((visibility("default"))) TS_SignOrCreationError_to_str(uint32_t o) {
37026         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
37027         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
37028         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
37029         Str_free(ret_str);
37030         return ret_conv;
37031 }
37032
37033 void  __attribute__((visibility("default"))) TS_InvoicePayer_free(uint32_t this_obj) {
37034         LDKInvoicePayer this_obj_conv;
37035         this_obj_conv.inner = (void*)(this_obj & (~1));
37036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37038         InvoicePayer_free(this_obj_conv);
37039 }
37040
37041 void  __attribute__((visibility("default"))) TS_Payer_free(uint32_t this_ptr) {
37042         if ((this_ptr & 1) != 0) return;
37043         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
37044         CHECK_ACCESS(this_ptr_ptr);
37045         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
37046         FREE((void*)this_ptr);
37047         Payer_free(this_ptr_conv);
37048 }
37049
37050 void  __attribute__((visibility("default"))) TS_Router_free(uint32_t this_ptr) {
37051         if ((this_ptr & 1) != 0) return;
37052         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
37053         CHECK_ACCESS(this_ptr_ptr);
37054         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
37055         FREE((void*)this_ptr);
37056         Router_free(this_ptr_conv);
37057 }
37058
37059 void  __attribute__((visibility("default"))) TS_RetryAttempts_free(uint32_t this_obj) {
37060         LDKRetryAttempts this_obj_conv;
37061         this_obj_conv.inner = (void*)(this_obj & (~1));
37062         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37064         RetryAttempts_free(this_obj_conv);
37065 }
37066
37067 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
37068         LDKRetryAttempts this_ptr_conv;
37069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37070         this_ptr_conv.is_owned = false;
37071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37072         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
37073         return ret_val;
37074 }
37075
37076 void  __attribute__((visibility("default"))) TS_RetryAttempts_set_a(uint32_t this_ptr, int64_t val) {
37077         LDKRetryAttempts this_ptr_conv;
37078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37079         this_ptr_conv.is_owned = false;
37080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37081         RetryAttempts_set_a(&this_ptr_conv, val);
37082 }
37083
37084 uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_new(int64_t a_arg) {
37085         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
37086         uint64_t ret_ref = 0;
37087         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37088         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37090         ret_ref = (uint64_t)ret_var.inner;
37091         if (ret_var.is_owned) {
37092                 ret_ref |= 1;
37093         }
37094         return ret_ref;
37095 }
37096
37097 static inline uint64_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
37098         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
37099 uint64_t ret_ref = 0;
37100 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37101 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37102 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37103 ret_ref = (uint64_t)ret_var.inner;
37104 if (ret_var.is_owned) {
37105         ret_ref |= 1;
37106 }
37107         return ret_ref;
37108 }
37109 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
37110         LDKRetryAttempts arg_conv;
37111         arg_conv.inner = (void*)(arg & (~1));
37112         arg_conv.is_owned = false;
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37114         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
37115         return ret_val;
37116 }
37117
37118 uint32_t  __attribute__((visibility("default"))) TS_RetryAttempts_clone(uint32_t orig) {
37119         LDKRetryAttempts orig_conv;
37120         orig_conv.inner = (void*)(orig & (~1));
37121         orig_conv.is_owned = false;
37122         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37123         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
37124         uint64_t ret_ref = 0;
37125         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37126         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37128         ret_ref = (uint64_t)ret_var.inner;
37129         if (ret_var.is_owned) {
37130                 ret_ref |= 1;
37131         }
37132         return ret_ref;
37133 }
37134
37135 jboolean  __attribute__((visibility("default"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
37136         LDKRetryAttempts a_conv;
37137         a_conv.inner = (void*)(a & (~1));
37138         a_conv.is_owned = false;
37139         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37140         LDKRetryAttempts b_conv;
37141         b_conv.inner = (void*)(b & (~1));
37142         b_conv.is_owned = false;
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37144         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
37145         return ret_val;
37146 }
37147
37148 int64_t  __attribute__((visibility("default"))) TS_RetryAttempts_hash(uint32_t o) {
37149         LDKRetryAttempts o_conv;
37150         o_conv.inner = (void*)(o & (~1));
37151         o_conv.is_owned = false;
37152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37153         int64_t ret_val = RetryAttempts_hash(&o_conv);
37154         return ret_val;
37155 }
37156
37157 void  __attribute__((visibility("default"))) TS_PaymentError_free(uint32_t this_ptr) {
37158         if ((this_ptr & 1) != 0) return;
37159         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
37160         CHECK_ACCESS(this_ptr_ptr);
37161         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
37162         FREE((void*)this_ptr);
37163         PaymentError_free(this_ptr_conv);
37164 }
37165
37166 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
37167         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
37168         *ret_copy = PaymentError_clone(arg);
37169 uint64_t ret_ref = (uint64_t)ret_copy;
37170         return ret_ref;
37171 }
37172 int64_t  __attribute__((visibility("default"))) TS_PaymentError_clone_ptr(uint32_t arg) {
37173         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
37174         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
37175         return ret_val;
37176 }
37177
37178 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_clone(uint32_t orig) {
37179         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
37180         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
37181         *ret_copy = PaymentError_clone(orig_conv);
37182         uint64_t ret_ref = (uint64_t)ret_copy;
37183         return ret_ref;
37184 }
37185
37186 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_invoice(jstring a) {
37187         LDKStr a_conv = str_ref_to_owned_c(a);
37188         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
37189         *ret_copy = PaymentError_invoice(a_conv);
37190         uint64_t ret_ref = (uint64_t)ret_copy;
37191         return ret_ref;
37192 }
37193
37194 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_routing(uint32_t a) {
37195         LDKLightningError a_conv;
37196         a_conv.inner = (void*)(a & (~1));
37197         a_conv.is_owned = (a & 1) || (a == 0);
37198         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37199         a_conv = LightningError_clone(&a_conv);
37200         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
37201         *ret_copy = PaymentError_routing(a_conv);
37202         uint64_t ret_ref = (uint64_t)ret_copy;
37203         return ret_ref;
37204 }
37205
37206 uint32_t  __attribute__((visibility("default"))) TS_PaymentError_sending(uint32_t a) {
37207         void* a_ptr = (void*)(((uint64_t)a) & ~1);
37208         CHECK_ACCESS(a_ptr);
37209         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
37210         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
37211         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
37212         *ret_copy = PaymentError_sending(a_conv);
37213         uint64_t ret_ref = (uint64_t)ret_copy;
37214         return ret_ref;
37215 }
37216
37217 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_new(uint32_t payer, uint32_t router, uint32_t scorer, uint32_t logger, uint32_t event_handler, uint32_t retry_attempts) {
37218         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
37219         CHECK_ACCESS(payer_ptr);
37220         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
37221         void* router_ptr = (void*)(((uint64_t)router) & ~1);
37222         CHECK_ACCESS(router_ptr);
37223         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
37224         LDKMultiThreadedLockableScore scorer_conv;
37225         scorer_conv.inner = (void*)(scorer & (~1));
37226         scorer_conv.is_owned = false;
37227         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
37228         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
37229         CHECK_ACCESS(logger_ptr);
37230         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37231         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
37232         CHECK_ACCESS(event_handler_ptr);
37233         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
37234         LDKRetryAttempts retry_attempts_conv;
37235         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
37236         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
37237         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
37238         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
37239         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
37240         uint64_t ret_ref = 0;
37241         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37242         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37244         ret_ref = (uint64_t)ret_var.inner;
37245         if (ret_var.is_owned) {
37246                 ret_ref |= 1;
37247         }
37248         return ret_ref;
37249 }
37250
37251 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
37252         LDKInvoicePayer this_arg_conv;
37253         this_arg_conv.inner = (void*)(this_arg & (~1));
37254         this_arg_conv.is_owned = false;
37255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37256         LDKInvoice invoice_conv;
37257         invoice_conv.inner = (void*)(invoice & (~1));
37258         invoice_conv.is_owned = false;
37259         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
37260         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
37261         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
37262         return (uint64_t)ret_conv;
37263 }
37264
37265 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_zero_value_invoice(uint32_t this_arg, uint32_t invoice, int64_t amount_msats) {
37266         LDKInvoicePayer this_arg_conv;
37267         this_arg_conv.inner = (void*)(this_arg & (~1));
37268         this_arg_conv.is_owned = false;
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37270         LDKInvoice invoice_conv;
37271         invoice_conv.inner = (void*)(invoice & (~1));
37272         invoice_conv.is_owned = false;
37273         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
37274         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
37275         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
37276         return (uint64_t)ret_conv;
37277 }
37278
37279 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_pay_pubkey(uint32_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
37280         LDKInvoicePayer this_arg_conv;
37281         this_arg_conv.inner = (void*)(this_arg & (~1));
37282         this_arg_conv.is_owned = false;
37283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37284         LDKPublicKey pubkey_ref;
37285         CHECK(*((uint32_t*)pubkey) == 33);
37286         memcpy(pubkey_ref.compressed_form, (uint8_t*)(pubkey + 4), 33);
37287         LDKThirtyTwoBytes payment_preimage_ref;
37288         CHECK(*((uint32_t*)payment_preimage) == 32);
37289         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
37290         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
37291         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
37292         return (uint64_t)ret_conv;
37293 }
37294
37295 void  __attribute__((visibility("default"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
37296         LDKInvoicePayer this_arg_conv;
37297         this_arg_conv.inner = (void*)(this_arg & (~1));
37298         this_arg_conv.is_owned = false;
37299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37300         unsigned char payment_hash_arr[32];
37301         CHECK(*((uint32_t*)payment_hash) == 32);
37302         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
37303         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
37304         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
37305 }
37306
37307 uint32_t  __attribute__((visibility("default"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
37308         LDKInvoicePayer this_arg_conv;
37309         this_arg_conv.inner = (void*)(this_arg & (~1));
37310         this_arg_conv.is_owned = false;
37311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37312         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
37313         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
37314         return (uint64_t)ret_ret;
37315 }
37316
37317 uint32_t  __attribute__((visibility("default"))) TS_create_invoice_from_channelmanager(uint32_t channelmanager, uint32_t keys_manager, uint32_t network, uint32_t amt_msat, jstring description) {
37318         LDKChannelManager channelmanager_conv;
37319         channelmanager_conv.inner = (void*)(channelmanager & (~1));
37320         channelmanager_conv.is_owned = false;
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
37322         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
37323         CHECK_ACCESS(keys_manager_ptr);
37324         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
37325         LDKCurrency network_conv = LDKCurrency_from_js(network);
37326         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
37327         CHECK_ACCESS(amt_msat_ptr);
37328         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
37329         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
37330         LDKStr description_conv = str_ref_to_owned_c(description);
37331         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
37332         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
37333         return (uint64_t)ret_conv;
37334 }
37335
37336 void  __attribute__((visibility("default"))) TS_DefaultRouter_free(uint32_t this_obj) {
37337         LDKDefaultRouter this_obj_conv;
37338         this_obj_conv.inner = (void*)(this_obj & (~1));
37339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37341         DefaultRouter_free(this_obj_conv);
37342 }
37343
37344 uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger) {
37345         LDKNetworkGraph network_graph_conv;
37346         network_graph_conv.inner = (void*)(network_graph & (~1));
37347         network_graph_conv.is_owned = false;
37348         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
37349         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
37350         CHECK_ACCESS(logger_ptr);
37351         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37352         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
37353         uint64_t ret_ref = 0;
37354         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37355         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37357         ret_ref = (uint64_t)ret_var.inner;
37358         if (ret_var.is_owned) {
37359                 ret_ref |= 1;
37360         }
37361         return ret_ref;
37362 }
37363
37364 uint32_t  __attribute__((visibility("default"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
37365         LDKDefaultRouter this_arg_conv;
37366         this_arg_conv.inner = (void*)(this_arg & (~1));
37367         this_arg_conv.is_owned = false;
37368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37369         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
37370         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
37371         return (uint64_t)ret_ret;
37372 }
37373
37374 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
37375         LDKChannelManager this_arg_conv;
37376         this_arg_conv.inner = (void*)(this_arg & (~1));
37377         this_arg_conv.is_owned = false;
37378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37379         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
37380         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
37381         return (uint64_t)ret_ret;
37382 }
37383
37384 uint32_t  __attribute__((visibility("default"))) TS_SiPrefix_from_str(jstring s) {
37385         LDKStr s_conv = str_ref_to_owned_c(s);
37386         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
37387         *ret_conv = SiPrefix_from_str(s_conv);
37388         return (uint64_t)ret_conv;
37389 }
37390
37391 uint32_t  __attribute__((visibility("default"))) TS_Invoice_from_str(jstring s) {
37392         LDKStr s_conv = str_ref_to_owned_c(s);
37393         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
37394         *ret_conv = Invoice_from_str(s_conv);
37395         return (uint64_t)ret_conv;
37396 }
37397
37398 uint32_t  __attribute__((visibility("default"))) TS_SignedRawInvoice_from_str(jstring s) {
37399         LDKStr s_conv = str_ref_to_owned_c(s);
37400         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
37401         *ret_conv = SignedRawInvoice_from_str(s_conv);
37402         return (uint64_t)ret_conv;
37403 }
37404
37405 jstring  __attribute__((visibility("default"))) TS_Invoice_to_str(uint32_t o) {
37406         LDKInvoice o_conv;
37407         o_conv.inner = (void*)(o & (~1));
37408         o_conv.is_owned = false;
37409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37410         LDKStr ret_str = Invoice_to_str(&o_conv);
37411         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
37412         Str_free(ret_str);
37413         return ret_conv;
37414 }
37415
37416 jstring  __attribute__((visibility("default"))) TS_SignedRawInvoice_to_str(uint32_t o) {
37417         LDKSignedRawInvoice o_conv;
37418         o_conv.inner = (void*)(o & (~1));
37419         o_conv.is_owned = false;
37420         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37421         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
37422         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
37423         Str_free(ret_str);
37424         return ret_conv;
37425 }
37426
37427 jstring  __attribute__((visibility("default"))) TS_Currency_to_str(uint32_t o) {
37428         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
37429         LDKStr ret_str = Currency_to_str(o_conv);
37430         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
37431         Str_free(ret_str);
37432         return ret_conv;
37433 }
37434
37435 jstring  __attribute__((visibility("default"))) TS_SiPrefix_to_str(uint32_t o) {
37436         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
37437         LDKStr ret_str = SiPrefix_to_str(o_conv);
37438         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
37439         Str_free(ret_str);
37440         return ret_conv;
37441 }
37442